1
0
mirror of https://github.com/django/django.git synced 2025-10-24 22:26:08 +00:00

Fixed #27344 -- Made ConditionalGetMiddleware only process GET requests.

This commit is contained in:
Kevin Christopher Henry
2016-10-13 00:31:48 -04:00
committed by Tim Graham
parent a4e9e834e3
commit 2327fad54e
2 changed files with 31 additions and 0 deletions

View File

@@ -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)