summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-06-17 07:21:09 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-06-17 07:21:09 +0000
commit9b397ee50d3ba3c29c754ad54b9181b4f300ea6f (patch)
treee87915de51414602e28a45d2709d9f46b53b8e7f
parentbccb8897e6ab0fe8d2e5b9bcb725ac28b1c8e566 (diff)
Changed ETag computation to first check if an ETag header already exists in the
response. git-svn-id: http://code.djangoproject.com/svn/django/trunk@5483 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/middleware/common.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/django/middleware/common.py b/django/middleware/common.py
index 5f671dff7d..9610e1e952 100644
--- a/django/middleware/common.py
+++ b/django/middleware/common.py
@@ -11,7 +11,8 @@ class CommonMiddleware(object):
- Forbids access to User-Agents in settings.DISALLOWED_USER_AGENTS
- URL rewriting: Based on the APPEND_SLASH and PREPEND_WWW settings,
- this middleware appends missing slashes and/or prepends missing "www."s.
+ this middleware appends missing slashes and/or prepends missing
+ "www."s.
- ETags: If the USE_ETAGS setting is set, ETags will be calculated from
the entire page content and Not Modified responses will be returned
@@ -74,7 +75,10 @@ class CommonMiddleware(object):
# Use ETags, if requested.
if settings.USE_ETAGS:
- etag = md5.new(response.content).hexdigest()
+ if response.has_header('ETag'):
+ etag = response['ETag']
+ else:
+ etag = md5.new(response.content).hexdigest()
if response.status_code >= 200 and response.status_code < 300 and request.META.get('HTTP_IF_NONE_MATCH') == etag:
response = http.HttpResponseNotModified()
else: