From cf3b26b84a186fe7f5f4ccba8daa69b38a822807 Mon Sep 17 00:00:00 2001 From: Patrick Uiterwijk Date: Tue, 23 May 2017 14:57:01 +0200 Subject: [PATCH] Prevent automatic gzip decompression by unsetting Accept-Encoding By not setting Accept-Encoding, servers will send Content-Type: x-gzip, which prevents urllib3 (on behalf of requests) from decompressing it. Fixes: #237 Signed-off-by: Patrick Uiterwijk --- oz/ozutil.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/oz/ozutil.py b/oz/ozutil.py index 7c75dc5..039c5a5 100644 --- a/oz/ozutil.py +++ b/oz/ozutil.py @@ -834,7 +834,8 @@ def http_download_file(url, fd, show_progress, logger): """ with requests.Session() as requests_session: requests_session.mount('file://', LocalFileAdapter()) - response = requests_session.get(url, stream=True, allow_redirects=True) + response = requests_session.get(url, stream=True, allow_redirects=True, + headers={'Accept-Encoding': ''}) file_size = int(response.headers.get('Content-Length')) chunk_size = 10*1024*1024 done = 0