From 25d1e8e418425a208eca285cbe435a5914da542c Mon Sep 17 00:00:00 2001 From: Jakub Roztocil Date: Mon, 7 Mar 2016 11:46:59 +0800 Subject: [PATCH] Add `Accept-Encoding: identity` for --download #423 --- httpie/downloads.py | 9 +++++---- tests/test_ssl.py | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/httpie/downloads.py b/httpie/downloads.py index e6064a354a..b49e335285 100644 --- a/httpie/downloads.py +++ b/httpie/downloads.py @@ -178,8 +178,8 @@ def pre_request(self, request_headers): :type request_headers: dict """ - # Disable content encoding so that we can resume, etc. - request_headers['Accept-Encoding'] = None + # Ask the server not to encode the content so that we can resume, etc. + request_headers['Accept-Encoding'] = 'identity' if self._resume: bytes_have = os.path.getsize(self._output_file.name) if bytes_have: @@ -201,6 +201,8 @@ def start(self, response): """ assert not self.status.time_started + # FIXME: some servers still might sent Content-Encoding: gzip + # try: total_size = int(response.headers['Content-Length']) except (KeyError, ValueError, TypeError): @@ -299,8 +301,7 @@ def __init__(self): def started(self, resumed_from=0, total_size=None): assert self.time_started is None - if total_size is not None: - self.total_size = total_size + self.total_size = total_size self.downloaded = self.resumed_from = resumed_from self.time_started = time() diff --git a/tests/test_ssl.py b/tests/test_ssl.py index a5ed54cd30..b226186e4c 100644 --- a/tests/test_ssl.py +++ b/tests/test_ssl.py @@ -13,6 +13,7 @@ CLIENT_KEY = os.path.join(TESTS_ROOT, 'client_certs', 'client.key') CLIENT_PEM = os.path.join(TESTS_ROOT, 'client_certs', 'client.pem') +# FIXME: # We test against a local httpbin instance which uses a self-signed cert. # Requests without --verify= will fail with a verification error. # See: https://github.com/kevin1024/pytest-httpbin#https-support