diff options
Diffstat (limited to 'django')
| -rw-r--r-- | django/middleware/gzip.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/django/middleware/gzip.py b/django/middleware/gzip.py index 642e3188d3..d6e2134f17 100644 --- a/django/middleware/gzip.py +++ b/django/middleware/gzip.py @@ -41,8 +41,12 @@ class GZipMiddleware(MiddlewareMixin): response.content = compressed_content response['Content-Length'] = str(len(response.content)) - if response.has_header('ETag'): - response['ETag'] = re.sub('"$', ';gzip"', response['ETag']) + # If there is a strong ETag, make it weak to fulfill the requirements + # of RFC 7232 section-2.1 while also allowing conditional request + # matches on ETags. + etag = response.get('ETag') + if etag and etag.startswith('"'): + response['ETag'] = 'W/' + etag response['Content-Encoding'] = 'gzip' return response |
