using the `StreamConsumedError`
authorTim Konick <konick781@gmail.com>
Mon, 22 Sep 2014 19:51:59 +0000 (15:51 -0400)
committerTim Konick <konick781@gmail.com>
Mon, 22 Sep 2014 19:51:59 +0000 (15:51 -0400)
requests/models.py

index 5974507bc4bfd223f917f6336746df930b5a282f..897cd6fd66d1429a51c95f9af923b172a14be3c4 100644 (file)
@@ -22,8 +22,9 @@ from .packages.urllib3.util import parse_url
 from .packages.urllib3.exceptions import (
     DecodeError, ReadTimeoutError, ProtocolError)
 from .exceptions import (
-    HTTPError, RequestException, MissingSchema, InvalidURL,
-    ChunkedEncodingError, ContentDecodingError, ConnectionError)
+    HTTPError, RequestException, MissingSchema, InvalidURL, 
+    ChunkedEncodingError, ContentDecodingError, ConnectionError, 
+    StreamConsumedError)
 from .utils import (
     guess_filename, get_auth_from_url, requote_uri,
     stream_decode_response_unicode, to_key_val_list, parse_header_links,
@@ -656,8 +657,7 @@ class Response(object):
             self._content_consumed = True
 
         if self._content_consumed and isinstance(self._content, bool):
-            raise RuntimeError(
-                        'The content for this response was already consumed')
+            raise StreamConsumedError()
         # simulate reading small chunks of the content
         reused_chunks = iter_slices(self._content, chunk_size)