Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upLet hyper automatically set the host header if needed #25294
Conversation
highfive
commented
Dec 14, 2019
|
Heads up! This PR modifies the following files:
|
highfive
commented
Dec 14, 2019
e4d6f39
to
4eb6e71
|
Two tests failed before. These tests compare request headers before hyper plays its role. When building a request we don't yet know if legacy HTTP/1.1 or modern HTTP/2 will be used when the actual connection is established, therefore it's rather an internal matter of hyper to add a Host header in case HTTP/2 is not used.
request expectation (right): host header containing localhost:45979 Explanation:
request expectation (right): host header containing localhost:37201 Explanation: |
|
Current PR modifies code at https://fetch.spec.whatwg.org/#http-network-or-cache-fetch step 5.16, the spec says:
Now the question is whether it is necessary or not. It could make sense to remove the host header only as late as possible before actually calling hyper. Probably around this line: servo/components/net/http_loader.rs Line 442 in 4eb6e71 |
|
So far I have not found a reason that would speak against the proposed patch:
|
|
I appreciate the detail you've provided here! I expect we're going to merge this as-is, but I'm waiting to merge any changes to fundamental parts of the engine like the network stack until we're finished submitting our Servo-based browser to the MS app store this week. |
|
@bors-servo r+ |
|
|
Let hyper automatically set the host header if needed Google's gws web server did not expect to receive an unneeded Host header via HTTP/2, therefore it responded with 400 Bad Request over a working HTTP/2 connection. https://tools.ietf.org/html/rfc7540#page-55 > Clients that generate HTTP/2 requests directly SHOULD use the ":authority" pseudo-header field instead of the Host header field. It's hyper's job to take care of this for the HTTP/1 case, therefore we can remove old code. When calling [Client::builder()](https://github.com/servo/servo/blob/1974c875a1fb12103a6916c58ed2cbef8c3e32a2/components/net/connector.rs#L116-L119) we do not disable hyper's default [set_host](https://github.com/hyperium/hyper/blob/4b6099c7aa558e6b1fda146ce6179cb0c67858d7/src/client/mod.rs#L1019-L1024) config option, therefore hyper [automatically adds a Host header for non-HTTP/2 connections](https://github.com/hyperium/hyper/blob/4b6099c7aa558e6b1fda146ce6179cb0c67858d7/src/client/mod.rs#L289-L292) based on the [URI](https://github.com/servo/servo/blob/3f663d7ab216a841e6250b5b10ce64d34caff97c/components/net/http_loader.rs#L418-L421). r? @jdm --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #25286.
|
|
|
@bors-servo retry |
Let hyper automatically set the host header if needed Google's gws web server did not expect to receive an unneeded Host header via HTTP/2, therefore it responded with 400 Bad Request over a working HTTP/2 connection. https://tools.ietf.org/html/rfc7540#page-55 > Clients that generate HTTP/2 requests directly SHOULD use the ":authority" pseudo-header field instead of the Host header field. It's hyper's job to take care of this for the HTTP/1 case, therefore we can remove old code. When calling [Client::builder()](https://github.com/servo/servo/blob/1974c875a1fb12103a6916c58ed2cbef8c3e32a2/components/net/connector.rs#L116-L119) we do not disable hyper's default [set_host](https://github.com/hyperium/hyper/blob/4b6099c7aa558e6b1fda146ce6179cb0c67858d7/src/client/mod.rs#L1019-L1024) config option, therefore hyper [automatically adds a Host header for non-HTTP/2 connections](https://github.com/hyperium/hyper/blob/4b6099c7aa558e6b1fda146ce6179cb0c67858d7/src/client/mod.rs#L289-L292) based on the [URI](https://github.com/servo/servo/blob/3f663d7ab216a841e6250b5b10ce64d34caff97c/components/net/http_loader.rs#L418-L421). r? @jdm --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #25286.
|
|
|
@bors-servo retry |
Let hyper automatically set the host header if needed Google's gws web server did not expect to receive an unneeded Host header via HTTP/2, therefore it responded with 400 Bad Request over a working HTTP/2 connection. https://tools.ietf.org/html/rfc7540#page-55 > Clients that generate HTTP/2 requests directly SHOULD use the ":authority" pseudo-header field instead of the Host header field. It's hyper's job to take care of this for the HTTP/1 case, therefore we can remove old code. When calling [Client::builder()](https://github.com/servo/servo/blob/1974c875a1fb12103a6916c58ed2cbef8c3e32a2/components/net/connector.rs#L116-L119) we do not disable hyper's default [set_host](https://github.com/hyperium/hyper/blob/4b6099c7aa558e6b1fda146ce6179cb0c67858d7/src/client/mod.rs#L1019-L1024) config option, therefore hyper [automatically adds a Host header for non-HTTP/2 connections](https://github.com/hyperium/hyper/blob/4b6099c7aa558e6b1fda146ce6179cb0c67858d7/src/client/mod.rs#L289-L292) based on the [URI](https://github.com/servo/servo/blob/3f663d7ab216a841e6250b5b10ce64d34caff97c/components/net/http_loader.rs#L418-L421). r? @jdm --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #25286.
|
|
Darkspirit commentedDec 14, 2019
Google's gws web server did not expect to receive an unneeded Host header via HTTP/2, therefore it responded with 400 Bad Request over a working HTTP/2 connection.
https://tools.ietf.org/html/rfc7540#page-55
It's hyper's job to take care of this for the HTTP/1 case, therefore we can remove old code.
When calling Client::builder() we do not disable hyper's default set_host config option, therefore hyper automatically adds a Host header for non-HTTP/2 connections based on the URI.
r? @jdm
./mach build -ddoes not report any errors./mach test-tidydoes not report any errors