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.
This commit is contained in:
Yohan Boniface 2023-02-27 13:47:12 +01:00
parent 6694306660
commit e343ddb636
2 changed files with 1 additions and 12 deletions

View file

@ -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, ))

View file

@ -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