This commit is contained in:
Jan Andre Ikenmeyer 2019-12-27 13:07:15 +01:00
parent 267ce462d8
commit 68ebecb775
No known key found for this signature in database
GPG key ID: 28F9E42748DD95AE
8 changed files with 254 additions and 16 deletions

View file

@ -100,6 +100,12 @@ impl<'a> Handler for Client<'a> {
}
}
self.http_state
.hsts_list
.write()
.unwrap()
.update_hsts_list_from_response(self.resource_url, &headers);
let _ = self
.event_sender
.send(WebSocketNetworkEvent::ConnectionEstablished {
@ -185,6 +191,7 @@ pub fn init(
thread::Builder::new()
.name(format!("WebSocket connection to {}", req_builder.url))
.spawn(move || {
let mut req_builder = req_builder;
let protocols = match req_builder.mode {
RequestMode::WebSocket { protocols } => protocols,
_ => panic!(
@ -192,6 +199,16 @@ pub fn init(
),
};
// https://fetch.spec.whatwg.org/#websocket-opening-handshake
// By standard, we should work with an http(s):// URL (req_url),
// but as ws-rs expects to be called with a ws(s):// URL (net_url)
// we upgrade ws to wss, so we don't have to convert http(s) back to ws(s).
http_state
.hsts_list
.read()
.unwrap()
.apply_hsts_rules(&mut req_builder.url);
let scheme = req_builder.url.scheme();
let mut req_url = req_builder.url.clone();
if scheme == "ws" {