diff options
author | Tim Burke <tim.burke@gmail.com> | 2015-05-21 22:44:36 -0700 |
---|---|---|
committer | Tim Burke <tim.burke@gmail.com> | 2016-08-30 15:38:55 -0700 |
commit | f728027bed59d08a6491ae9c14d2f5968f8d6fa3 (patch) | |
tree | 5dad1390ace6471f55d2c017a151e424db1e3d18 /swiftclient/client.py | |
parent | 20e0c515bf23841015102fb72d61ab18c826c036 (diff) | |
download | python-swiftclient-f728027bed59d08a6491ae9c14d2f5968f8d6fa3.tar.gz |
Accept gzip-encoded API responses
Previously, we would accept gzip-encoded responses, but only because we
were letting requests decode *all* responses (even object data). This
restores the previous capability, but with tighter controls about which
requests will accept gzipped responses and where the decoding happens.
Change-Id: I4fd8b97207b9ab01b1bcf825cc16efd8ad46344a
Related-Bug: 1282861
Related-Bug: 1338464
Diffstat (limited to 'swiftclient/client.py')
-rw-r--r-- | swiftclient/client.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/swiftclient/client.py b/swiftclient/client.py index 988c7d9..64885cf 100644 --- a/swiftclient/client.py +++ b/swiftclient/client.py @@ -732,7 +732,7 @@ def get_account(url, token, marker=None, limit=None, prefix=None, if end_marker: qs += '&end_marker=%s' % quote(end_marker) full_path = '%s?%s' % (parsed.path, qs) - headers = {'X-Auth-Token': token} + headers = {'X-Auth-Token': token, 'Accept-Encoding': 'gzip'} if service_token: headers['X-Service-Token'] = service_token method = 'GET' @@ -859,6 +859,7 @@ def get_container(url, token, container, marker=None, limit=None, else: headers = {} headers['X-Auth-Token'] = token + headers['Accept-Encoding'] = 'gzip' if full_listing: rv = get_container(url, token, container, marker, limit, prefix, delimiter, end_marker, path, http_conn, @@ -1457,10 +1458,11 @@ def get_capabilities(http_conn): :raises ClientException: HTTP Capabilities GET failed """ parsed, conn = http_conn - conn.request('GET', parsed.path, '') + headers = {'Accept-Encoding': 'gzip'} + conn.request('GET', parsed.path, '', headers) resp = conn.getresponse() body = resp.read() - http_log((parsed.geturl(), 'GET',), {'headers': {}}, resp, body) + http_log((parsed.geturl(), 'GET',), {'headers': headers}, resp, body) if resp.status < 200 or resp.status >= 300: raise ClientException.from_response( resp, 'Capabilities GET failed', body) |