From d573cb021e69854d947dd988b6c9e492a688a377 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Fri, 22 Jul 2005 18:12:05 +0000 Subject: [PATCH] Fixed #112 -- WSGI handler now displays proper text status. Thanks, sune.kirkeby@gmail.com! git-svn-id: http://code.djangoproject.com/svn/django/trunk@297 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/handlers/wsgi.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/django/core/handlers/wsgi.py b/django/core/handlers/wsgi.py index 4e82a1be7a..75415ab5ad 100644 --- a/django/core/handlers/wsgi.py +++ b/django/core/handlers/wsgi.py @@ -1,6 +1,12 @@ from django.utils import datastructures, httpwrappers from pprint import pformat +STATUS_CODE_TEXT = { + 200: 'OK', + 404: 'NOT FOUND', + 500: 'INTERNAL SERVER ERROR', +} + class WSGIRequest(httpwrappers.HttpRequest): def __init__(self, environ): self.environ = environ @@ -121,7 +127,11 @@ class WSGIHandler: for middleware_method in self._response_middleware: response = middleware_method(request, response) - status = str(response.status_code) + ' ' # TODO: Extra space here is a hack. + try: + status_text = STATUS_CODE_TEXT[response.status_code] + except KeyError: + status_text = 'UNKNOWN STATUS CODE' + status = '%s %s' % (response.status_code, status_text) response_headers = response.headers if response.cookies: response_headers['Set-Cookie'] = response.cookies.output(header='')