Skip to content
Myr

redirection docs

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

authored by Kenneth Reitz · committed by Kenneth Reitz · parent 0a24de2 · Browse files · 1 file+37 added−0 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+37 added−0 removed

  • other:+37 added−0 removed

1 file+37 added−0 removed

modified:docs/user/quickstart.rst+37 added
245 unmodified lines
246 >>> requests.get(url, auth=('digest', 'user', 'pass'))247 <Response [200]>248249250Redirection and History251-----------------------252253Requests will automatically perform location redirection while using impodotent methods.254255GitHub redirects all HTTP requests to HTTPS. Let's see what happens::256257 >>> r = request.get('http://github.com')258 >>> r.url259 'https://github.com/'260 >>> r.status_code261 200262 >>> r.history263 [<Response [301]>]264265The :class:`Response.history` list contains a list of the266:class:`Request` objects that were created in order to complete the request.267268If you're using GET, HEAD, or OPTIONS, you can disable redirection269handling with the ``disable_redirects`` parameter::270271 >>> r = request.get('http://github.com')272 >>> r.status_code273 301274 >>> r.history275 []276277If you're using POST, PUT, PATCH, *&c*, you can also explicitly enable redirection as well::278279 >>> r = request.post('http://github.com')280 >>> r.url281 'https://github.com/'282 >>> r.history283 [<Response [301]>]284285286287-----------------------288289Ready for more? Check out the :ref:`advanced <advanced>` section.