-
Notifications
You must be signed in to change notification settings - Fork 5.4k
[native] Fix blank HTTP Host header in requests #24929
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
[native] Fix blank HTTP Host header in requests #24929
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ZacBlanco, LGTM.
c669bee
to
06fdfa6
Compare
@@ -244,7 +244,6 @@ class RequestBuilder { | |||
send(HttpClient* client, const std::string& body = "", int64_t delayMs = 0) { | |||
addJwtIfConfigured(); | |||
header(proxygen::HTTP_HEADER_CONTENT_LENGTH, std::to_string(body.size())); | |||
headers_.ensureHostHeader(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think send
is used other places too, can this be left in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is this will always set the Host
header as an empty string because the HttpMessage doesn't have a dstAddress set. It isn't possible to get the dstAddress except for when the client actually sends the request. If the Host header gets set to empty, then subsequent calls to ensureHostHeader
are a no-op
06fdfa6
to
f08764e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ZacBlanco
Because the request's destination address wasn't set inside of the RequestBuilder object, the Host was populated with a blank value. On older HTTP versions this is permissible, but on newer ones (such as Jetty 12), this is a hard error and results in the request being rejected with a 400 error. This change properly sets the request destination address so that ensureHostHeader sets the correct value.
f08764e
to
7a445d8
Compare
Description
This change properly sets the request destination address so that ensureHostHeader sets the correct value for the HTTP
Host
header.Motivation and Context
Because the request's destination address wasn't set inside of the RequestBuilder object, the Host was populated with a blank value. On older HTTP servers this is permissible, but on newer ones (such as the incoming Jetty 12 upgrade), this is a hard error and results in the request being rejected with a 400 error.
Impact
N/A
Test Plan
Existing tests
Contributor checklist
Release Notes