aboutsummaryrefslogtreecommitdiff
path: root/requests/packages/urllib3/response.py
diff options
context:
space:
mode:
authorSVN-Git Migration <python-modules-team@lists.alioth.debian.org>2015-10-08 13:41:25 -0700
committerSVN-Git Migration <python-modules-team@lists.alioth.debian.org>2015-10-08 13:41:25 -0700
commit9f376f89bdf80a40914218d64cd9cd61b25f449d (patch)
tree6205015b49c53a3178573532cfcd10dcd7f2d121 /requests/packages/urllib3/response.py
parentd4aa2de2bb89ca384ad81db731bb99735e1db788 (diff)
downloadpython-requests-9f376f89bdf80a40914218d64cd9cd61b25f449d.tar
python-requests-9f376f89bdf80a40914218d64cd9cd61b25f449d.tar.gz
Imported Upstream version 1.1.0
Diffstat (limited to 'requests/packages/urllib3/response.py')
-rw-r--r--requests/packages/urllib3/response.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/requests/packages/urllib3/response.py b/requests/packages/urllib3/response.py
index 5fab824..833be62 100644
--- a/requests/packages/urllib3/response.py
+++ b/requests/packages/urllib3/response.py
@@ -10,7 +10,7 @@ import zlib
from io import BytesIO
-from .exceptions import HTTPError
+from .exceptions import DecodeError
from .packages.six import string_types as basestring
@@ -130,7 +130,9 @@ class HTTPResponse(object):
after having ``.read()`` the file object. (Overridden if ``amt`` is
set.)
"""
- content_encoding = self.headers.get('content-encoding')
+ # Note: content-encoding value should be case-insensitive, per RFC 2616
+ # Section 3.5
+ content_encoding = self.headers.get('content-encoding', '').lower()
decoder = self.CONTENT_DECODERS.get(content_encoding)
if decode_content is None:
decode_content = self._decode_content
@@ -148,9 +150,9 @@ class HTTPResponse(object):
try:
if decode_content and decoder:
data = decoder(data)
- except IOError:
- raise HTTPError("Received response with content-encoding: %s, but "
- "failed to decode it." % content_encoding)
+ except (IOError, zlib.error):
+ raise DecodeError("Received response with content-encoding: %s, but "
+ "failed to decode it." % content_encoding)
if cache_content:
self._body = data