-
-
Notifications
You must be signed in to change notification settings - Fork 29.1k
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
HEAD requests should be HEAD requests upon redirect #99730
Comments
@haampie is there anything I can do to help with this issue/PR? |
I guess it should be compared to other tools. A while after reporting this issue and implementing my own redirect handler, I hit some issue where sending a HEAD request to a server that redirects to an AWS bucket with temporary credentials would only work if the redirect was using a GET request, and error with Unauthorized if it was HEAD. Dunno how common this is. |
OK, here's confirmation that the requests package stays with HEAD:
And I'm seeing Here's an MDN doc that doesn't come down strongly on one side or the other. |
@orsenthil any thoughts on this issue, whether the request handling can be updated to not change a HEAD to a GET on a redirect? |
The PR #99731 is approved. We will merge this change, and make the behavior change. |
Merged; it'll be in 3.13. |
Bug report
Currently the following is
False
But this is
True
This is because
http://google.com
redirects with 302 tohttp://www.google.com
.This means that checking for existence of some file by URL will actually download the file when the URL responds with a redirect. This makes no sense. Also the HTTP spec says nothing about changing HEAD requests into GET requests; it just says that everything but GET and HEAD requests should require user interaction on redirect, which Python violates, but there's a comment on that explaining it's an active choice to violate the spec there.
To me it seems like this is an oversight. Note that
curl -LI http://google.com
also sticks to HEAD requests.Linked PRs
The text was updated successfully, but these errors were encountered: