#12747: Custom HTTP status reason phrases are not supported ------------------------------------------------------------------------+--- Reporter: Gustavo | Owner: nobody Status: new | Milestone: 1.2 Component: HTTP handling | Version: 1.1 Keywords: http status, http status reason, http status reason phrase | Stage: Unreviewed Has_patch: 1 | ------------------------------------------------------------------------+--- At present, Django hard-codes the ''HTTP status reason phrases'' based on an integer that represents the ''HTTP status code'', forcing the recommended phrases by the HTTP specification.
Note they are just the recommended/default phrases and developers should be allowed to override these phrases. For example, I may want to return the following and Django should allow me to do so: {{{ 403 Get out }}} Or, {{{ 200 Everything is fine }}} See: http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6.1.1 In order to support this, Django could have the following code in ''django.http:HttpResponse.__init!__'': {{{ if isinstance(status, basestring): # The status is given as a real HTTP status header, so we should # tell the code and the reason apart for Django: (status_code, status_reason) = status.split(" ", 1) status_code = int(status_code) self.status_reason = status_reason or None else: # The status has been given the old way supported by Django, simply # the status code as an integer: status_code = status self.status_reason = None }}} And the following on ''django.core.handlers.wsgi:WSGIHandler.__call!__()'': {{{ if response.status_reason: status_text = "%s %s" % (response.status_code, response.status_reason) else: try: status_text = STATUS_CODE_TEXT[response.status_code] except KeyError: status_text = 'UNKNOWN STATUS CODE' }}} If any Django user wants to use this functionality before it gets implemented, they may use twod.wsgi: http://bitbucket.org/2degrees/twod.wsgi/ -- Ticket URL: <http://code.djangoproject.com/ticket/12747> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-upda...@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.