Skip to content
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

Remove duplicate Host header from initial websocket request. #26622

Merged
merged 1 commit into from May 24, 2020
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Remove duplicate Host header from initial websocket request.

  • Loading branch information
jdm committed May 22, 2020
commit 63cdcb847dce6d2abcaf0589218f4b2ccae60efa
@@ -8,9 +8,7 @@ use crate::fetch::methods::should_be_blocked_due_to_bad_port;
use crate::hosts::replace_host;
use crate::http_loader::HttpState;
use embedder_traits::resources::{self, Resource};
use headers::Host;
use http::header::{self, HeaderMap, HeaderName, HeaderValue};
use http::uri::Authority;
use ipc_channel::ipc::{IpcReceiver, IpcSender};
use ipc_channel::router::ROUTER;
use net_traits::request::{RequestBuilder, RequestMode};
@@ -34,7 +32,6 @@ use ws::{Error as WebSocketError, ErrorKind as WebSocketErrorKind, Result as Web
#[derive(Clone)]
struct Client<'a> {
origin: &'a str,
host: &'a Host,
protocols: &'a [String],
http_state: &'a Arc<HttpState>,
resource_url: &'a ServoUrl,
@@ -60,10 +57,6 @@ impl<'a> Handler for Client<'a> {
let mut req = Request::from_url(url)?;
req.headers_mut()
.push(("Origin".to_string(), self.origin.as_bytes().to_owned()));
req.headers_mut().push((
"Host".to_string(),
format!("{}", self.host).as_bytes().to_owned(),
));

for protocol in self.protocols {
req.add_protocol(protocol);
@@ -228,23 +221,8 @@ pub fn init(
let mut net_url = req_builder.url.clone().into_url();
net_url.set_host(Some(&host)).unwrap();

let host = Host::from(
format!(
"{}{}",
req_builder.url.host_str().unwrap(),
req_builder
.url
.port_or_known_default()
.map(|v| format!(":{}", v))
.unwrap_or("".into())
)
.parse::<Authority>()
.unwrap(),
);

let client = Client {
origin: &req_builder.origin.ascii_serialization(),
host: &host,
protocols: &protocols,
http_state: &http_state,
resource_url: &req_builder.url,
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.