summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2014-11-04 22:19:10 +0200
committerTim Graham <timograham@gmail.com>2014-11-04 17:56:57 -0500
commitdf0523debcc2d0984f1bc11d323f04227d4b388b (patch)
tree59fe14bb211ba8e0e3c93af7f031a1d6fb5fd602 /django
parent83daf53636da676bc3a32b957168e9205714198e (diff)
Fixed #23531 -- Added CommonMiddleware.response_redirect_class.
Diffstat (limited to 'django')
-rw-r--r--django/middleware/common.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/django/middleware/common.py b/django/middleware/common.py
index c719f9e9a3..0bf0481df6 100644
--- a/django/middleware/common.py
+++ b/django/middleware/common.py
@@ -30,11 +30,16 @@ class CommonMiddleware(object):
urlpatterns, then an HTTP-redirect is returned to this new URL;
otherwise the initial URL is processed as usual.
+ This behavior can be customized by subclassing CommonMiddleware and
+ overriding the response_redirect_class attribute.
+
- ETags: If the USE_ETAGS setting is set, ETags will be calculated from
the entire page content and Not Modified responses will be returned
appropriately.
"""
+ response_redirect_class = http.HttpResponsePermanentRedirect
+
def process_request(self, request):
"""
Check for denied User-Agents and rewrite the URL based on
@@ -100,7 +105,7 @@ class CommonMiddleware(object):
newurl += '?' + request.META['QUERY_STRING'].decode()
except UnicodeDecodeError:
pass
- return http.HttpResponsePermanentRedirect(newurl)
+ return self.response_redirect_class(newurl)
def process_response(self, request, response):
"""