Prefetch must be false to use response.raw.
authorCory Benfield <lukasaoz@gmail.com>
Tue, 4 Dec 2012 18:10:33 +0000 (18:10 +0000)
committerCory Benfield <lukasaoz@gmail.com>
Tue, 4 Dec 2012 18:10:33 +0000 (18:10 +0000)
Resolves issue #979.

docs/user/quickstart.rst
requests/models.py

index 159d651a5b6d26fc6342ba7745eb06d3c8f5fdd7..31848b09960a96c882f090af102c227ff66e70fe 100644 (file)
@@ -137,12 +137,13 @@ In case the JSON decoding fails, ``r.json`` simply returns ``None``.
 Raw Response Content
 --------------------
 
-In the rare case that you'd like to get the absolute raw socket response from the server,
-you can access ``r.raw``::
+In the rare case that you'd like to get the raw socket response from the
+server, you can access ``r.raw``. If you want to do this, make sure you set
+``prefetch=False`` in your initial request. Once you do, you can do this::
 
+    >>> r = requests.get('https:/github.com/timeline.json', prefetch=False)
     >>> r.raw
     <requests.packages.urllib3.response.HTTPResponse object at 0x101194810>
-
     >>> r.raw.read(10)
     '\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03'
 
index 045b3a5801593bf9dbcbfc1422ac2d337131460c..10c858762756b7613e8f8195d5e70a5bf38bc6b8 100644 (file)
@@ -700,6 +700,8 @@ class Response(object):
         self.headers = CaseInsensitiveDict()
 
         #: File-like object representation of response (for advanced usage).
+        #: Requires that ``prefetch=False` on the request.
+        # This requirement does not apply for use internally to Requests.
         self.raw = None
 
         #: Final URL location of Response.