Commit 06b0c83c authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Fixed content-encoding on archive api with gzipped archives.

parent 99257551
......@@ -644,7 +644,17 @@ def get_calc(upload_hash, calc_hash):
try:
archive = ArchiveFile(archive_id)
arhchive_path = archive.os_path
return send_file(arhchive_path, attachment_filename=os.path.basename(arhchive_path))
rv = send_file(
arhchive_path,
mimetype='application/json',
as_attachment=True,
attachment_filename=os.path.basename(arhchive_path))
if config.files.compress_archive:
rv.headers['Content-Encoding'] = 'gzip'
return rv
except KeyError:
abort(404, message='Archive %s does not exist.' % archive_id)
except FileNotFoundError:
......
import pytest
import time
import json
import zlib
import re
from mongoengine import connect
from mongoengine.connection import disconnect
......@@ -153,7 +154,7 @@ def test_processing(client, file, mode, worker, mocksearch, test_user_auth, no_w
upload_id = upload['upload_id']
upload_cmd = upload['upload_command']
headers = dict(Authorization='Basic %s' % re.search(r'.*-HAuthorization: Basic ([^\s]+).*', upload_cmd).group(1))
headers = dict(Authorization='Basic %s' % re.search(r'.*Authorization: Basic ([^\s]+).*', upload_cmd).group(1))
upload_endpoint = '/uploads/%s' % upload_id
upload_file_endpoint = '%s/file' % upload_endpoint
......@@ -266,6 +267,12 @@ def test_repo_calcs_user_invisible(client, example_elastic_calc, test_other_user
def test_get_archive(client, archive, no_warn):
rv = client.get('/archive/%s' % archive.object_id)
if rv.headers.get('Content-Encoding') == 'gzip':
json.loads(zlib.decompress(rv.data, 16 + zlib.MAX_WBITS))
else:
json.loads(rv.data)
assert rv.status_code == 200
......
......@@ -75,7 +75,7 @@ def archive_config(monkeypatch, request):
config.files.uploads_bucket,
config.files.repository_bucket,
config.files.archive_bucket,
request)
request.param)
monkeypatch.setattr(config, 'files', new_config)
yield
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment