Skip to content
Myr

simplify

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 91ac5ba · Browse files · 2 files+13 added−8 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+13 added−8 removed

  • other:+13 added−8 removed

2 files+13 added−8 removed

modified:requests/models.py+4 added-8 removed
23 unmodified lines
24from .exceptions import (25 ConnectionError, HTTPError, RequestException, Timeout, TooManyRedirects,26 URLRequired, SSLError)27from .utils import (28 get_encoding_from_headers, stream_decode_response_unicode,29 stream_decompress, guess_filename, requote_uri, dict_from_string)28 get_encoding_from_headers, stream_untransfer, guess_filename, requote_uri,29 dict_from_string)3031from .compat import urlparse, urlunparse, urljoin, urlsplit, urlencode, quote, unquote, str, bytes, SimpleCookie, is_py3, is_py23233# Import chardet if it is available.
649 unmodified lines
683 gen = generate_chunked()684 else:685 gen = generate()686687 if 'gzip' in self.headers.get('content-encoding', ''):688 gen = stream_decompress(gen, mode='gzip')689 elif 'deflate' in self.headers.get('content-encoding', ''):690 gen = stream_decompress(gen, mode='deflate')687 gen = stream_untransfer(gen, self)688689 if decode_unicode:690 gen = stream_decode_response_unicode(gen, self)691
33 unmodified lines
725 # Yield the last line726 if pending is not None:727 yield pending.rstrip()728732729 @property730 def content(self):731 """Content of the response, in bytes."""732
3 unmodified lines
736 if self._content_consumed:737 raise RuntimeError(738 'The content for this response was already consumed')739744 self._content = self.raw.read()740 self._content = bytes('').join(self.iter_content()) or None741 except AttributeError:742 self._content = None743744 self._content_consumed = True
50 unmodified lines
modified:requests/utils.py+9 added
398 unmodified lines
399 rv = buf + dec.flush()400 if rv:401 yield rv402403def stream_untransfer(gen, resp):404 if 'gzip' in resp.headers.get('content-encoding', ''):405 gen = stream_decompress(gen, mode='gzip')406 elif 'deflate' in resp.headers.get('content-encoding', ''):407 gen = stream_decompress(gen, mode='deflate')408409 return gen410411412# The unreserved URI characters (RFC 3986)413UNRESERVED_SET = frozenset(414 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"415 + "0123456789-._~")
30 unmodified lines