Skip to content
Myr

Correctly reflect redirection behaviour.

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

The docs incorrectly listed HEAD as a method that follows redirects by default: it does not. This commit resolves this issue, and thus resolves issue #504.

authored by Cory Benfield · committed by Cory Benfield · parent 45506d1 · Browse files · 1 file+5 added−5 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+5 added−5 removed

  • other:+5 added−5 removed

1 file+5 added−5 removed

modified:docs/user/quickstart.rst+5 added-5 removed
356 unmodified lines
357358Redirection and History359-----------------------360361Requests will automatically perform location redirection while using362idempotent methods, such as GET.361Requests will automatically perform location redirection while using the GET362and OPTIONS verbs.363364GitHub redirects all HTTP requests to HTTPS. We can use the ``history`` method365of the Response object to track redirection. Let's see what Github does::366
7 unmodified lines
374375The :class:`Response.history` list contains a list of the376:class:`Request` objects that were created in order to complete the request.377378If you're using GET, HEAD, or OPTIONS, you can disable redirection379handling with the ``allow_redirects`` parameter::378If you're using GET or OPTIONS, you can disable redirection handling with the379``allow_redirects`` parameter::380381 >>> r = requests.get('http://github.com', allow_redirects=False)382 >>> r.status_code383 301384 >>> r.history385 []386387If you're using POST, PUT, PATCH, *&c*, you can also explicitly enable387If you're using POST, PUT, PATCH, DELETE or HEAD, you can enable388redirection as well::389390 >>> r = requests.post('http://github.com', allow_redirects=True)391 >>> r.url
48 unmodified lines