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:
committed by
Tim Graham
parent
a4e9e834e3
commit
2327fad54e
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user