From: Cory Benfield Date: Tue, 4 Dec 2012 18:10:33 +0000 (+0000) Subject: Prefetch must be false to use response.raw. X-Git-Tag: v1.0.0~82^2~3^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=93b2be48f0db93d96495212da96257051ae24ee9;p=services%2Fpython-requests.git Prefetch must be false to use response.raw. Resolves issue #979. --- diff --git a/docs/user/quickstart.rst b/docs/user/quickstart.rst index 159d651..31848b0 100644 --- a/docs/user/quickstart.rst +++ b/docs/user/quickstart.rst @@ -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 - >>> r.raw.read(10) '\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03' diff --git a/requests/models.py b/requests/models.py index 045b3a5..10c8587 100644 --- a/requests/models.py +++ b/requests/models.py @@ -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.