Skip to content
Myr

Merge pull request #2241 from tijko/master

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

raise RuntimeError when a single streamed request calls *iter methods th...

authored by Kenneth Reitz · committed by Kenneth Reitz · parents 1e79cf6, 64ba451 · Browse files · 2 files+8 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+8 added−2 removed

  • other:+8 added−2 removed

2 files+8 added−2 removed

modified:requests/exceptions.py+3 added
87 unmodified lines
888990class ContentDecodingError(RequestException, BaseHTTPError):91 """Failed to decode response content"""9293class StreamConsumedError(RequestException, TypeError):94 """The content for this response was already consumed"""
modified:requests/models.py+5 added-2 removed
20 unmodified lines
21from .packages.urllib3.util import parse_url22from .packages.urllib3.exceptions import (23 DecodeError, ReadTimeoutError, ProtocolError)24from .exceptions import (25 HTTPError, RequestException, MissingSchema, InvalidURL,26 ChunkedEncodingError, ContentDecodingError, ConnectionError)25 HTTPError, RequestException, MissingSchema, InvalidURL, 26 ChunkedEncodingError, ContentDecodingError, ConnectionError, 27 StreamConsumedError)28from .utils import (29 guess_filename, get_auth_from_url, requote_uri,30 stream_decode_response_unicode, to_key_val_list, parse_header_links,31 iter_slices, guess_json_utf, super_len, to_native_string)
635 unmodified lines
667 yield chunk668669 self._content_consumed = True670671 if self._content_consumed and isinstance(self._content, bool):672 raise StreamConsumedError()673 # simulate reading small chunks of the content674 reused_chunks = iter_slices(self._content, chunk_size)675676 stream_chunks = generate()
157 unmodified lines