diff --git a/Cargo.toml b/Cargo.toml index ec0b5c1..b339e0e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,10 +19,10 @@ tls = ["native-tls"] [dependencies] base64 = "0.11.0" byteorder = "1.3.2" -bytes = "0.4.12" -http = "0.1.19" +bytes = "0.5" +http = "0.2" httparse = "1.3.4" -input_buffer = "0.2.0" +input_buffer = "0.3.0" log = "0.4.8" rand = "0.7.2" sha-1 = "0.8.1" diff --git a/src/handshake/server.rs b/src/handshake/server.rs index f665a0b..fb75192 100644 --- a/src/handshake/server.rs +++ b/src/handshake/server.rs @@ -75,15 +75,14 @@ pub fn create_response(request: &Request) -> Result { .get("Sec-WebSocket-Key") .ok_or_else(|| Error::Protocol("Missing Sec-WebSocket-Key".into()))?; - let mut response = Response::builder(); - - response.status(StatusCode::SWITCHING_PROTOCOLS); - response.version(request.version()); - response.header("Connection", "Upgrade"); - response.header("Upgrade", "websocket"); - response.header("Sec-WebSocket-Accept", convert_key(key.as_bytes())?); - - Ok(response.body(())?) + let builder = Response::builder() + .status(StatusCode::SWITCHING_PROTOCOLS) + .version(request.version()) + .header("Connection", "Upgrade") + .header("Upgrade", "websocket") + .header("Sec-WebSocket-Accept", convert_key(key.as_bytes())?); + + Ok(builder.body(())?) } // Assumes that this is a valid response