Skip to content

Commit

Permalink
Merge pull request psf#1675 from houqp/master
Browse files Browse the repository at this point in the history
fix doc for redirction and history
  • Loading branch information
Lukasa committed Oct 16, 2013
2 parents 65ec319 + 3d0a1eb commit 2ec1bdd
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions docs/user/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,7 @@ parameter::
Redirection and History
-----------------------

Requests will automatically perform location redirection while using the GET
and OPTIONS verbs.
Requests will automatically perform location redirection except for HEAD verb.

GitHub redirects all HTTP requests to HTTPS. We can use the ``history`` method
of the Response object to track redirection. Let's see what GitHub does::
Expand All @@ -357,17 +356,16 @@ The :class:`Response.history` list contains the :class:`Request` objects that
were created in order to complete the request. The list is sorted from the
oldest to the most recent request.

If you're using GET or OPTIONS, you can disable redirection handling with the
``allow_redirects`` parameter::
If you're using GET, OPTIONS, POST, PUT, PATCH or DELETE, you can disable
redirection handling with the ``allow_redirects`` parameter::

>>> r = requests.get('http://github.com', allow_redirects=False)
>>> r.status_code
301
>>> r.history
[]

If you're using POST, PUT, PATCH, DELETE or HEAD, you can enable
redirection as well::
If you're using HEAD, you can enable redirection as well::

>>> r = requests.post('http://github.com', allow_redirects=True)
>>> r.url
Expand Down

0 comments on commit 2ec1bdd

Please sign in to comment.