-
Notifications
You must be signed in to change notification settings - Fork 9
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
Redirection issue #53
Comments
Hi @pineman , Thx for the report. I'm struggling a bit to understand what is the expectation. Can you provide a code snippet of what you're doing, and run it with HTTPX_DEBUG=2 env var, and explain what was the expectation and what httpx is doing differently? FWIW httpx defaults to HTTP/2, which does not support the Host header (HTTP.rb only uses v1, so that may be the difference). |
I've made a patch here (branch as for the "host" header, I' fairly sure you're using HTTP/2 in your example. If you're able to dump the httpx log here, we can confirm that. FWIW the equivalent in HTTP/2 is the |
Hey @HoneyryderChuck! Sorry, I didn't get the time to send you a more detailed log. |
remove body-related headers on POST-to-GET redirects See merge request os85/httpx!343
I hit another snag so I thought I'd report it. I'm not an expert in HTTP at all, so please excuse any inaccuracies/ignorance - I'm just noting this issue just in case it might be valuable.
I'm hitting a very weird endpoint which redirects a lot, sometimes absolutely, and I found is super finicky with the
Host
andContent-Type
headers. It's a POST request with url form encoded body, so httpx sets the content-type header appropriately. I'm using the redirections plugin.I found httpx's behavior to differ from HTTP.rb's when receiving the redirection status in the response.
First, I believe httpx isn't setting
Host
in the first request, so I set it manually myself. Unsure if it should or not, just noting what I saw regarding differences.When the redirect response comes, the second request doesn't change the
Host
header according to the response'sLocation
header (it's an absolute redirect to a different host entirely, so it's debatable if that's even valid behavior in the first place?).I also found httpx doesn't clear the
Content-Type
andContent-Length
headers for the second request.I found that adding:
right at the start of the
redirect_request_headers
method made my usecase work.Again, I'm unsure of the correct semantics here, but hope this info may be valuable. Thanks!
The text was updated successfully, but these errors were encountered: