big docs update on workflow of request lifecycle

This commit is contained in:
Kenneth Reitz
2011-11-12 18:23:19 -05:00
parent 3462d9c87b
commit 0a24de2ef9
+21
View File
@@ -46,6 +46,27 @@ Any dictionaries that you pass to a request method will be merged with the sessi
All values that are contained within a session are directly available to you. See the :ref:`Session API Docs <sessionapi>` to learn more.
Body Content Workflow
----------------------
By default, When you make a request, the body of the response isn't downloaded immediately. The response headers are downloaded when you make a request, but the content isn't downloaded until you access the :class:`Response.content` attribute.
Let's walk through it::
tarball_url = 'https://github.com/kennethreitz/requests/tarball/master'
r = requests.get(tarball_url)
The request has been made, but the connection is still open. The response body has not been downloaded yet. ::
r.content
The content has been downloaded and cached.
You can override this default behavior with the ``prefetch`` parameter::
r = requests.get(tarball_url, prefetch=True)
# Blocks until all of request body has been downloaded.
Configuring Requests
--------------------