-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Streamed request with preset Host header sends two Host headers #4392
Comments
Yep, this looks like a miss from #3637. Since we're not using urllib3's chunked request interface, we never got the change integrated in Requests. The quick path here is to carry the host dedupe logic from urrlib3 into that try block. The better but likely more involved solution would be to try to use urllib3's chunked logic in Requests. This is something we've discussed before but probably out of scope for this issue. @requests/core I'm assuming the former option is the advisable one, but do you have different thoughts? |
I think we can probably use urllib3’s implementation: it’s present in all our supported versions of urllib3 I think. |
If we're going to swap in urllib3's chunked logic, we need better end-to-end (socket level) tests of our chunking behaviour to make sure we don't drastically change things. |
Does anyone know a work-around to avoid this double host header? I need to access a frustrating and honestly quite stupid API that I have no control over, which requires the host header to be some kind of information totally unrelated to the actual hostname. And it requires chunked encoding. |
Currently the best work-around you have is to not use |
Any update on this? |
Linking #5391 back here as a potential fix as converting to urllib3's chunked functionality is unlikely to happen before a major version bump. |
Requests is now using urllib3's chunking API |
The following code sends two host headers:
(I tested with
nc -vvl 3000
on OS X).Headers received:
This is because when chunking a request, we don't tell the
httplib
/http.client
library to skip the host header if one is already set. From theadapters.HTTPAdapter.send()
implementation:which leaves the
skip_host
parameter set toFalse
. It probably should useskip_host='host' in request.headers
here.System Information
The text was updated successfully, but these errors were encountered: