From fdf932c61c7ff77d494a4a413cc5fbdb71328ac7 Mon Sep 17 00:00:00 2001 From: Tim Konick Date: Mon, 22 Sep 2014 12:04:29 -0400 Subject: [PATCH] raise RuntimeError when a single streamed request calls *iter methods than once --- requests/models.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/requests/models.py b/requests/models.py index bbf08c8..a6af642 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() -- 2.34.1