From ee6b17187fbf19d498c16bd46ec6dd6aaf86f453 Mon Sep 17 00:00:00 2001 From: Viktor Lomakin Date: Wed, 9 Oct 2019 12:20:17 +0300 Subject: Fixed #30812 -- Made ConditionalGetMiddleware set ETag only for responses with non-empty content. --- django/utils/cache.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'django/utils') diff --git a/django/utils/cache.py b/django/utils/cache.py index 2b37acfd44..3ee01a1e94 100644 --- a/django/utils/cache.py +++ b/django/utils/cache.py @@ -98,7 +98,7 @@ def get_max_age(response): def set_response_etag(response): - if not response.streaming: + if not response.streaming and response.content: response['ETag'] = quote_etag(hashlib.md5(response.content).hexdigest()) return response -- cgit v1.3