diff options
author | Philip Lamb <phil.git@eden.net.nz> | 2024-04-17 00:38:25 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-16 12:38:25 +0000 |
commit | 7a507a4d5b35e572916bb387a5d2fb0c642660fa (patch) | |
tree | 861880d565efd17089c1d8f73c1466359553d391 /components | |
parent | f5bdfdfe94d05dfb7a98063304fe5b9b01229aba (diff) | |
download | servo-7a507a4d5b35e572916bb387a5d2fb0c642660fa.tar.gz servo-7a507a4d5b35e572916bb387a5d2fb0c642660fa.zip |
Backout `Host`-header related change from #32024. (#32093)
#32024 broke a different set of nginx sites, and a more sophisticated fix for the case of a missing HTTP 1.1 `Host` header is required.
Diffstat (limited to 'components')
-rw-r--r-- | components/net/http_loader.rs | 15 | ||||
-rw-r--r-- | components/net/tests/fetch.rs | 9 | ||||
-rw-r--r-- | components/net/tests/http_loader.rs | 2 |
3 files changed, 1 insertions, 25 deletions
diff --git a/components/net/http_loader.rs b/components/net/http_loader.rs index 3044526c1c9..9332eca67b1 100644 --- a/components/net/http_loader.rs +++ b/components/net/http_loader.rs @@ -1225,20 +1225,7 @@ async fn http_network_or_cache_fetch( // Step 5.16 let current_url = http_request.current_url(); - if !http_request.headers.contains_key(header::HOST) { - let host = if current_url.port().is_none() { - current_url.host_str().unwrap().to_string() - } else { - format!( - "{}:{}", - current_url.host_str().unwrap(), - current_url.port().unwrap() - ) - }; - http_request.headers.typed_insert(headers::Host::from( - host.parse::<http::uri::Authority>().unwrap(), - )); - } + http_request.headers.remove(header::HOST); // unlike http_loader, we should not set the accept header // here, according to the fetch spec diff --git a/components/net/tests/fetch.rs b/components/net/tests/fetch.rs index 7b9a140bcb4..6faf1d362e3 100644 --- a/components/net/tests/fetch.rs +++ b/components/net/tests/fetch.rs @@ -1359,15 +1359,6 @@ fn test_fetch_with_devtools() { headers.typed_insert::<UserAgent>(DEFAULT_USER_AGENT.parse().unwrap()); - let host = if url.port().is_none() { - url.host_str().unwrap().to_string() - } else { - format!("{}:{}", url.host_str().unwrap(), url.port().unwrap()) - }; - headers.typed_insert(headers::Host::from( - host.parse::<http::uri::Authority>().unwrap(), - )); - headers.insert( header::ACCEPT_ENCODING, HeaderValue::from_static("gzip, deflate, br"), diff --git a/components/net/tests/http_loader.rs b/components/net/tests/http_loader.rs index 6c551440a82..324b75daa7f 100644 --- a/components/net/tests/http_loader.rs +++ b/components/net/tests/http_loader.rs @@ -266,8 +266,6 @@ fn test_request_and_response_data_with_network_messages() { //Creating default headers for request let mut headers = HeaderMap::new(); - headers.insert(header::HOST, HeaderValue::from_static("bar.foo")); - headers.insert( header::ACCEPT, HeaderValue::from_static("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"), |