diff options
| author | Kevin Christopher Henry <k@severian.com> | 2016-10-13 00:31:48 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-10-17 16:11:53 -0400 |
| commit | 2327fad54e334119f2561ddddf52e5af4bb14d41 (patch) | |
| tree | 2184a9d21428c98ca099430eb7850670bb652509 /django/middleware/http.py | |
| parent | a4e9e834e3dfc8d5a024a78c765f193105d41a48 (diff) | |
Fixed #27344 -- Made ConditionalGetMiddleware only process GET requests.
Diffstat (limited to 'django/middleware/http.py')
| -rw-r--r-- | django/middleware/http.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/django/middleware/http.py b/django/middleware/http.py index a075ccfe79..41389d930e 100644 --- a/django/middleware/http.py +++ b/django/middleware/http.py @@ -18,6 +18,12 @@ class ConditionalGetMiddleware(MiddlewareMixin): if not response.streaming and not response.has_header('Content-Length'): response['Content-Length'] = str(len(response.content)) + # It's too late to prevent an unsafe request with a 412 response, and + # for a HEAD request, the response body is always empty so computing + # an accurate ETag isn't possible. + if request.method != 'GET': + return response + if self.needs_etag(response) and not response.has_header('ETag'): set_response_etag(response) |
