summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Konick <konick781@gmail.com>2014-09-22 12:04:29 -0400
committerTim Konick <konick781@gmail.com>2014-09-22 12:04:29 -0400
commitfdf932c61c7ff77d494a4a413cc5fbdb71328ac7 (patch)
tree162c5e12d1da204d24283c0b9080640d5900ff35
parentd28d45af915adcc964f1621e8115b40b2db0cbba (diff)
downloadpython-requests-fdf932c61c7ff77d494a4a413cc5fbdb71328ac7.tar.gz
raise RuntimeError when a single streamed request calls *iter methods than once
-rw-r--r--requests/models.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/requests/models.py b/requests/models.py
index bbf08c81..a6af6427 100644
--- a/requests/models.py
+++ b/requests/models.py
@@ -655,8 +655,12 @@ class Response(object):
self._content_consumed = True
- # simulate reading small chunks of the content
- reused_chunks = iter_slices(self._content, chunk_size)
+ if self._content_consumed and isinstance(self._content, bool):
+ raise RuntimeError(
+ 'The content for this response was already consumed')
+ else:
+ # simulate reading small chunks of the content
+ reused_chunks = iter_slices(self._content, chunk_size)
stream_chunks = generate()