Skip to content
Myr

Automatically decompress gzipped responses if content-type is set. fixes #19

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Kenneth Reitz · committed by Kenneth Reitz · parent 23d5761 · Browse files · 1 file+8 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+8 added−1 removed

  • other:+8 added−1 removed

1 file+8 added−1 removed

modified:requests/core.py+8 added-1 removed
12 unmodified lines
13from __future__ import absolute_import1415import urllib16import urllib217import zlib1819from urllib2 import HTTPError20from urlparse import urlparse21
122 unmodified lines
144 """Build internal Response object from given response."""145146 self.response.status_code = getattr(resp, 'code', None)147 self.response.headers = getattr(resp.info(), 'dict', None)147 self.response.url = getattr(resp, 'url', None)148 self.response.content = resp.read()149150 if self.response.headers.get('content-encoding', None) == 'gzip':151 try:152 self.response.content = zlib.decompress(self.response.content, 16+zlib.MAX_WBITS)153 except zlib.error:154 pass155156 self.response.url = getattr(resp, 'url', None)157158 @staticmethod159 def _build_url(url, data):160 """Build URLs."""161
360 unmodified lines