Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix allow_redirects #40

Closed
espenhogbakk opened this issue May 26, 2011 · 2 comments
Closed

Fix allow_redirects #40

espenhogbakk opened this issue May 26, 2011 · 2 comments

Comments

@espenhogbakk
Copy link

Hi,

I have problems with the "allow_redirects" to the Request object. It seems that if you specify "allow_redirects=False" it still follows redirects. I think I've found the source of the problem on line 169 in models.py:

while (
            ('location' in r.headers) and
            ((self.method in ('GET', 'HEAD')) or
            (r.status_code is 303) or
            (self.allow_redirects))
        ):

Shouldt the or (self.allow_redirects) be and (self.allow_redirects)?

@kennethreitz
Copy link
Contributor

When allow_redirects is set to True, the redirection of non-GET/HEAD requests is allowed. RFC 2616 10.3 says that these redirects should only occur w/ permission of the user (therefore, the flag).

When allow_redirects is set to False (default), GET and HEAD requests are redirected as usual, and a 301 result of a POST, will not be redirected.

@kennethreitz
Copy link
Contributor

I'm considering renaming allow_redirects to avoid confusion.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants