From a8dee3fa072bbb04a94a51365e9d6fff58f01847 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Thu, 23 Feb 2023 11:17:19 +0100 Subject: [PATCH] Add Vary: Accept-Encoding header --- umap/tests/test_datalayer_views.py | 1 + umap/views.py | 1 + 2 files changed, 2 insertions(+) diff --git a/umap/tests/test_datalayer_views.py b/umap/tests/test_datalayer_views.py index d88bdd69..01fd5c64 100644 --- a/umap/tests/test_datalayer_views.py +++ b/umap/tests/test_datalayer_views.py @@ -28,6 +28,7 @@ def test_get(client, settings, datalayer): assert response['ETag'] is not None assert response['Last-Modified'] is not None assert response['Cache-Control'] is not None + assert response['Vary'] == 'Accept-Encoding' assert 'Content-Encoding' not in response j = json.loads(response.content.decode()) assert '_umap_options' in j diff --git a/umap/views.py b/umap/views.py index 55f307fe..8ab823d2 100644 --- a/umap/views.py +++ b/umap/views.py @@ -744,6 +744,7 @@ class DataLayerView(GZipMixin, BaseDetailView): response["Last-Modified"] = http_date(statobj.st_mtime) response['ETag'] = '"%s"' % hashlib.md5(force_bytes(response.content)).hexdigest() # noqa response['Content-Length'] = len(response.content) + response['Vary'] = 'Accept-Encoding' if path.endswith(self.EXT): response['Content-Encoding'] = 'gzip' return response