Skip to content
Myr

utils.decode_gzip

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 f038ec3 · Browse files · 2 files+9 added−2 removed
This commit

State

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

Diff stats

2 files+9 added−2 removed

  • other:+9 added−2 removed

2 files+9 added−2 removed

modified:requests/models.py+2 added-2 removed
19 unmodified lines
20from .monkeys import Request as _Request, HTTPBasicAuthHandler, HTTPForcedBasicAuthHandler, HTTPDigestAuthHandler, HTTPRedirectHandler21from .structures import CaseInsensitiveDict22from .packages.poster.encode import multipart_encode23from .packages.poster.streaminghttp import register_openers, get_handlers24from .utils import dict_from_cookiejar, get_unicode_from_response24from .utils import dict_from_cookiejar, get_unicode_from_response, decode_gzip25from .status_codes import codes26from .exceptions import RequestException, AuthenticationError, Timeout, URLRequired, InvalidMethod, TooManyRedirects2728
418 unmodified lines
447448 # Decode GZip'd content.449 if 'gzip' in self.headers.get('content-encoding', ''):450 try:451 self._content = zlib.decompress(self._content, 16+zlib.MAX_WBITS)451 self._content = decode_gzip(self._content)452 except zlib.error:453 pass454455 # Decode unicode content.
197 unmodified lines
modified:requests/utils.py+7 added
10 unmodified lines
1112import cgi13import cookielib14import re15import zlib161718def dict_from_cookiejar(cookiejar):19 """Returns a key/value dictionary from a CookieJar."""
111 unmodified lines
131 try:132 return unicode(r.content, encoding, errors='replace')133 except TypeError:134 return r.content135136137def decode_gzip(content):138 """Return gzip-decoded string."""139140 return zlib.decompress(content, 16+zlib.MAX_WBITS)