-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Problem with 301-redirect #1360
Comments
Uh...can I ask you to uninstall and reinstall Requests? The TypeError that got thrown should have been impossible to hit, because it's inside a Try/Catch block that catches TypeErrors. |
Ignore the first trace (I'll delete it), the key of the problem is:
|
Ah, ok, got it. The issue is that the remote server is not following RFC 2616. The Location header should be percent-encoded, and hasn't been. This doesn't matter if you pass the URL through Requests from the top, because it gets percent-encoded by prepare_url. EDIT: To be clear, we should handle this: I'll have a fix ready shortly. |
Lucasa, thank you very much - now works fine |
`requote_uri` was added in 2013 in psf#1361 to resolve psf#1360. But in 2019 this was also solved in `urllib3` in urllib3/urllib3#1647. Not only does the `urllib3` implementation more closely match what all other clients are doing. It also means that we are double-encoding invalid uris. If the redirect is invalid we're in unchartered territory but the path that `requests` uses has no chance to decode to the same that any other client uses, even to the most lenient server. Simply drop `requote_uri`, as `urllib3`'s `parse_url` will always handle invalid urls.
`requote_uri` was added in 2013 in psf#1361 to resolve psf#1360. But in 2019 this was also solved in `urllib3` in urllib3/urllib3#1647. Not only does the `urllib3` implementation more closely match what all other clients are doing. It also means that we are double-encoding invalid uris. If the redirect is invalid we're in unchartered territory but the path that `requests` uses has no chance to decode to the same that any other client uses, even to the most lenient server. Simply drop `requote_uri`, as `urllib3`'s `parse_url` will always handle invalid urls.
`requote_uri` was added in 2013 in psf#1361 to resolve psf#1360. But in 2019 this was also solved in `urllib3` in urllib3/urllib3#1647. Not only does the `urllib3` implementation more closely match what all other clients are doing. It also means that we are double-encoding invalid uris. If the redirect is invalid we're in unchartered territory but the path that `requests` uses has no chance to decode to the same that any other client uses, even to the most lenient server. Simply drop `requote_uri`, as `urllib3`'s `parse_url` will always handle invalid urls.
`requote_uri` was added in 2013 in psf#1361 to resolve psf#1360. But in 2019 this was also solved in `urllib3` in urllib3/urllib3#1647. Not only does the `urllib3` implementation more closely match what all other clients are doing. It also means that we are double-encoding invalid uris. If the redirect is invalid we're in unchartered territory but the path that `requests` uses has no chance to decode to the same that any other client uses, even to the most lenient server. Simply drop `requote_uri`, as `urllib3`'s `parse_url` will always handle invalid urls.
I have a problem with downloading a file, when the server returns the 301 code:
If you do redirect manually - it works fine:
The problem appears to Python 3.3 and python-requests-1.2.0/python-requests-dev
The text was updated successfully, but these errors were encountered: