From d62d6e68e003ef97f051e304c37bb2310e76fd3e Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Wed, 28 Feb 2018 14:16:55 -0800 Subject: [PATCH] use new version of http crate --- Cargo.toml | 2 +- src/ws/client.rs | 9 ++++----- src/ws/mod.rs | 23 +++++++++-------------- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0780053d0..085878302 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,7 +42,7 @@ brotli2 = "^0.3.2" failure = "0.1.1" flate2 = "1.0" h2 = "0.1" -http = "^0.1.2" +http = "^0.1.5" httparse = "1.2" http-range = "0.1" libc = "0.2" diff --git a/src/ws/client.rs b/src/ws/client.rs index 587d60a65..e160016be 100644 --- a/src/ws/client.rs +++ b/src/ws/client.rs @@ -197,11 +197,11 @@ impl WsClient { self.request.upgrade(); self.request.set_header(header::UPGRADE, "websocket"); self.request.set_header(header::CONNECTION, "upgrade"); - self.request.set_header("SEC-WEBSOCKET-VERSION", "13"); + self.request.set_header(header::SEC_WEBSOCKET_VERSION, "13"); self.request.with_connector(self.conn.clone()); if let Some(protocols) = self.protocols.take() { - self.request.set_header("SEC-WEBSOCKET-PROTOCOL", protocols.as_str()); + self.request.set_header(header::SEC_WEBSOCKET_PROTOCOL, protocols.as_str()); } let request = match self.request.finish() { Ok(req) => req, @@ -249,7 +249,7 @@ impl WsClientHandshake { let key = base64::encode(&sec_key); request.headers_mut().insert( - HeaderName::try_from("SEC-WEBSOCKET-KEY").unwrap(), + header::SEC_WEBSOCKET_KEY, HeaderValue::try_from(key.as_str()).unwrap()); let (tx, rx) = unbounded(); @@ -328,8 +328,7 @@ impl Future for WsClientHandshake { return Err(WsClientError::MissingConnectionHeader) } - if let Some(key) = resp.headers().get( - HeaderName::try_from("SEC-WEBSOCKET-ACCEPT").unwrap()) + if let Some(key) = resp.headers().get(header::SEC_WEBSOCKET_ACCEPT) { // field is constructed by concatenating /key/ // with the string "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" (RFC 6455) diff --git a/src/ws/mod.rs b/src/ws/mod.rs index 90b2558b7..8cd4d9207 100644 --- a/src/ws/mod.rs +++ b/src/ws/mod.rs @@ -70,11 +70,6 @@ pub use self::context::WebsocketContext; pub use self::client::{WsClient, WsClientError, WsClientReader, WsClientWriter, WsClientHandshake}; -const SEC_WEBSOCKET_ACCEPT: &str = "SEC-WEBSOCKET-ACCEPT"; -const SEC_WEBSOCKET_KEY: &str = "SEC-WEBSOCKET-KEY"; -const SEC_WEBSOCKET_VERSION: &str = "SEC-WEBSOCKET-VERSION"; -// const SEC_WEBSOCKET_PROTOCOL: &'static str = "SEC-WEBSOCKET-PROTOCOL"; - /// Websocket errors #[derive(Fail, Debug)] @@ -222,11 +217,11 @@ pub fn handshake(req: &HttpRequest) -> Result(req: &HttpRequest) -> Result(req: &HttpRequest) -> Result