diff options
| author | Joseph Kocherhans <joseph@jkocherhans.com> | 2007-11-30 04:32:25 +0000 |
|---|---|---|
| committer | Joseph Kocherhans <joseph@jkocherhans.com> | 2007-11-30 04:32:25 +0000 |
| commit | 4d52c80dd1b4c6aef9407b268ae720eeffd4d962 (patch) | |
| tree | 08e126f78db9968aa0830d1f092ed226e09e87b5 /django/core | |
| parent | 8b3d65e517f3127ff8929ba4caaea32937fb776b (diff) | |
newforms-admin: Merged from trunk up to [6670]. This is just before auto-escaping was checked in.
git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@6761 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/core')
| -rw-r--r-- | django/core/handlers/base.py | 28 | ||||
| -rw-r--r-- | django/core/handlers/modpython.py | 1 | ||||
| -rw-r--r-- | django/core/handlers/wsgi.py | 2 |
3 files changed, 16 insertions, 15 deletions
diff --git a/django/core/handlers/base.py b/django/core/handlers/base.py index 13c7f4193f..1796cae8ea 100644 --- a/django/core/handlers/base.py +++ b/django/core/handlers/base.py @@ -4,6 +4,10 @@ from django import http import sys class BaseHandler(object): + # Changes that are always applied to a response (in this order). + response_fixes = [http.fix_location_header, + http.conditional_content_removal] + def __init__(self): self._request_middleware = self._view_middleware = self._response_middleware = self._exception_middleware = None @@ -50,10 +54,6 @@ class BaseHandler(object): def get_response(self, request): "Returns an HttpResponse object for the given HttpRequest" - response = self._real_get_response(request) - return fix_location_header(request, response) - - def _real_get_response(self, request): from django.core import exceptions, urlresolvers from django.core.mail import mail_admins from django.conf import settings @@ -134,15 +134,13 @@ class BaseHandler(object): import traceback return '\n'.join(traceback.format_exception(*(exc_info or sys.exc_info()))) -def fix_location_header(request, response): - """ - Ensure that we always use an absolute URI in any location header in the - response. This is required by RFC 2616, section 14.30. - - Code constructing response objects is free to insert relative paths and - this function converts them to absolute paths. - """ - if 'Location' in response and request.get_host(): - response['Location'] = request.build_absolute_uri(response['Location']) - return response + def apply_response_fixes(self, request, response): + """ + Applies each of the functions in self.response_fixes to the request and + response, modifying the response in the process. Returns the new + response. + """ + for func in self.response_fixes: + response = func(request, response) + return response diff --git a/django/core/handlers/modpython.py b/django/core/handlers/modpython.py index 2a3e03f3dd..e81a65be4d 100644 --- a/django/core/handlers/modpython.py +++ b/django/core/handlers/modpython.py @@ -162,6 +162,7 @@ class ModPythonHandler(BaseHandler): # Apply response middleware for middleware_method in self._response_middleware: response = middleware_method(request, response) + response = self.apply_response_fixes(request, response) finally: dispatcher.send(signal=signals.request_finished) diff --git a/django/core/handlers/wsgi.py b/django/core/handlers/wsgi.py index d06eee73f2..94575ca369 100644 --- a/django/core/handlers/wsgi.py +++ b/django/core/handlers/wsgi.py @@ -207,6 +207,7 @@ class WSGIHandler(BaseHandler): # Apply response middleware for middleware_method in self._response_middleware: response = middleware_method(request, response) + response = self.apply_response_fixes(request, response) finally: dispatcher.send(signal=signals.request_finished) @@ -220,3 +221,4 @@ class WSGIHandler(BaseHandler): response_headers.append(('Set-Cookie', str(c.output(header='')))) start_response(status, response_headers) return response + |
