diff --git a/components/net/http_loader.rs b/components/net/http_loader.rs index 26d886375d4a7..bb4bc2009365e 100644 --- a/components/net/http_loader.rs +++ b/components/net/http_loader.rs @@ -177,7 +177,7 @@ pub fn set_default_accept_language(headers: &mut HeaderMap) { // TODO(eijebong): Change this once typed headers are done headers.insert( header::ACCEPT_LANGUAGE, - HeaderValue::from_static("en-US, en; q=0.5"), + HeaderValue::from_static("en-US,en;q=0.5"), ); } @@ -1225,7 +1225,17 @@ async fn http_network_or_cache_fetch( // Step 5.16 let current_url = http_request.current_url(); - http_request.headers.remove(header::HOST); + 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::() + .unwrap(), + )); + } // unlike http_loader, we should not set the accept header // here, according to the fetch spec diff --git a/components/shared/net/quality.rs b/components/shared/net/quality.rs index 095cd121badbd..aedc2722340be 100644 --- a/components/shared/net/quality.rs +++ b/components/shared/net/quality.rs @@ -59,9 +59,9 @@ where fmt::Display::fmt(&self.item, fmt)?; match self.quality.0 { 1000 => Ok(()), - 0 => fmt.write_str("; q=0"), + 0 => fmt.write_str(";q=0"), mut x => { - fmt.write_str("; q=0.")?; + fmt.write_str(";q=0.")?; let mut digits = *b"000"; digits[2] = (x % 10) as u8 + b'0'; x /= 10; @@ -81,7 +81,7 @@ pub fn quality_to_value(q: Vec>) -> HeaderValue { &q.iter() .map(|q| q.to_string()) .collect::>() - .join(", "), + .join(","), ) .unwrap() }