Skip to content
Myr

Merge pull request #1675 from houqp/master

Before adoption: this commit came in with the history the project adopted, so no landing records it.

fix doc for redirction and history

authored by Cory Benfield · committed by Cory Benfield · parents 65ec319, 3d0a1eb · Browse files · 1 file+4 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+4 added−6 removed

  • other:+4 added−6 removed

1 file+4 added−6 removed

modified:docs/user/quickstart.rst+4 added-6 removed
337 unmodified lines
338339Redirection and History340-----------------------341342Requests will automatically perform location redirection while using the GET343and OPTIONS verbs.342Requests will automatically perform location redirection except for HEAD verb.343344GitHub redirects all HTTP requests to HTTPS. We can use the ``history`` method345of the Response object to track redirection. Let's see what GitHub does::346
8 unmodified lines
355The :class:`Response.history` list contains the :class:`Request` objects that356were created in order to complete the request. The list is sorted from the357oldest to the most recent request.358360If you're using GET or OPTIONS, you can disable redirection handling with the361``allow_redirects`` parameter::359If you're using GET, OPTIONS, POST, PUT, PATCH or DELETE, you can disable360redirection handling with the ``allow_redirects`` parameter::361362 >>> r = requests.get('http://github.com', allow_redirects=False)363 >>> r.status_code364 301365 >>> r.history366 []367369If you're using POST, PUT, PATCH, DELETE or HEAD, you can enable370redirection as well::368If you're using HEAD, you can enable redirection as well::369370 >>> r = requests.post('http://github.com', allow_redirects=True)371 >>> r.url372 'https://github.com/'
45 unmodified lines