From e343ddb6368aa54f7a1c441ea93eb974a417a117 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Mon, 27 Feb 2023 13:47:12 +0100 Subject: [PATCH] Do not deal with gzip while serving without x-accel-redirect Let's keep this path simple, as it should not be used in normal production context. --- umap/tests/test_datalayer_views.py | 8 -------- umap/views.py | 5 +---- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/umap/tests/test_datalayer_views.py b/umap/tests/test_datalayer_views.py index ef00b822..e4c71324 100644 --- a/umap/tests/test_datalayer_views.py +++ b/umap/tests/test_datalayer_views.py @@ -85,14 +85,6 @@ def test_should_not_be_possible_to_delete_with_wrong_map_id_in_url(client, datal assert DataLayer.objects.filter(pk=datalayer.pk).exists() -def test_get_gzipped(client, datalayer, settings): - url = reverse('datalayer_view', args=(datalayer.pk, )) - response = client.get(url, HTTP_ACCEPT_ENCODING='gzip') - assert response['Last-Modified'] is not None - assert response['Cache-Control'] is not None - assert response['Content-Encoding'] == 'gzip' - - def test_optimistic_concurrency_control_with_good_last_modified(client, datalayer, map, post_data): # noqa # Get Last-Modified url = reverse('datalayer_view', args=(datalayer.pk, )) diff --git a/umap/views.py b/umap/views.py index 1f9cdcac..8736c1dd 100644 --- a/umap/views.py +++ b/umap/views.py @@ -720,16 +720,13 @@ class DataLayerView(GZipMixin, BaseDetailView): response[settings.UMAP_XSENDFILE_HEADER] = path else: # Do not use in production - # (no cache-control/If-Modified-Since/If-None-Match) + # (no gzip/cache-control/If-Modified-Since/If-None-Match) statobj = os.stat(path) with open(path, "rb") as f: # Should not be used in production! response = HttpResponse(f.read(), content_type="application/geo+json") response["Last-Modified"] = self.last_modified response["Content-Length"] = statobj.st_size - response["Vary"] = "Accept-Encoding" - if accepts_gzip and settings.UMAP_GZIP: - response["Content-Encoding"] = "gzip" return response