Skip to content
Myr

Merge branch 'redsea' into develop

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 · parents 9ba93b8, 6c359b2 · Browse files · 3 files+21 added−28 removed
This commit

State

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

Diff stats

3 files+21 added−28 removed

  • other:+21 added−28 removed

3 files+21 added−28 removed

modified:requests/defaults.py+1 added-5 removed
8 unmodified lines
9Configurations:1011:base_headers: Default HTTP headers.12:verbose: Stream to write request logging to.13:timeout: Seconds until request timeout.14:max_redirects: Maximum number of redirects allowed within a request.13:max_redirects: Maximum number of redirects allowed within a request.s15:decode_unicode: Decode unicode responses automatically?14:keep_alive: Reuse HTTP Connections?15:max_retries: The number of times a request should be retried in the event of a connection failure.16:danger_mode: If true, Requests will raise errors immediately.17:safe_mode: If true, Requests will catch all errors.18:pool_maxsize: The maximium size of an HTTP connection pool.19:pool_connections: The number of active HTTP connection pools to use.2220"""2122from . import __version__23
7 unmodified lines
31}3233defaults['verbose'] = None34defaults['max_redirects'] = 3038defaults['decode_unicode'] = True35defaults['pool_connections'] = 1036defaults['pool_maxsize'] = 1037defaults['max_retries'] = 038defaults['danger_mode'] = False
2 unmodified lines
modified:requests/models.py+17 added-23 removed
150 unmodified lines
151 def __repr__(self):152 return '<Request [%s]>' % (self.method)153154155 def _build_response(self, resp, is_error=False):155 def _build_response(self, resp):156 """Build internal :class:`Response <Response>` object157 from given response.158 """159
30 unmodified lines
190 response.error = getattr(resp, 'error', None)191192 # Save original response for later.193 response.raw = resp194195 if is_error:196 response.error = resp197194 response.url = self.full_url.decode('utf-8')195196 return response197
408 unmodified lines
606 return False607 return True608609614 def iter_content(self, chunk_size=10 * 1024, decode_unicode=None):610 def iter_content(self, chunk_size=10 * 1024, decode_unicode=False):611 """Iterates over the response data. This avoids reading the content612 at once into memory for large responses. The chunk size is the number613 of bytes it should read into memory. This is not necessarily the614 length of each item returned as decoding can take place.
45 unmodified lines
660 gen = stream_decompress(gen, mode='gzip')661 elif 'deflate' in self.headers.get('content-encoding', ''):662 gen = stream_decompress(gen, mode='deflate')663668 if decode_unicode is None:669 decode_unicode = self.config.get('decode_unicode')670664 if decode_unicode:665 gen = stream_decode_response_unicode(gen, self)666667 return gen
29 unmodified lines
697698699 @property700 def content(self):708 """Content of the response, in bytes or unicode709 (if available).710 """701 """Content of the response, in bytes."""702703 if self._content is None:704 # Read the contents.705 try:
4 unmodified lines
710 self._content = self.raw.read()711 except AttributeError:712 self._content = None713714 self._content_consumed = True723 content = self._content715 return self._content716725 # Decode unicode content.726 if self.config.get('decode_unicode'):717728 # Try charset from content-type718 @property719 def text(self):720 """Content of the response, in unicode."""721730 if self.encoding:731 try:732 content = unicode(content, self.encoding)733 except UnicodeError:734 pass722 # Try charset from content-type723 content = u''724736 # Fall back:725 if self.encoding:726 try:727 content = unicode(self.content, self.encoding)728 except UnicodeError:729 pass730731 # Try to fall back:732 try:733 content = unicode(content, self.encoding, errors='replace')734 except TypeError:735 pass736742 self._content_consumed = True737 return content738739740 def raise_for_status(self):
15 unmodified lines
modified:requests/utils.py+3 added
274 unmodified lines
275276 if 'charset' in params:277 return params['charset'].strip("'\"")278279 if 'text' in content_type:280 return 'ISO-8859-1'281282283def unicode_from_html(content):284 """Attempts to decode an HTML string into unicode.285 If unsuccessful, the original content is returned.286 """
115 unmodified lines