Update to http 0.2

pull/98/head
Sebastian Dröge 5 years ago
parent 1da9614ab2
commit c2f713b6bb
  1. 2
      Cargo.toml
  2. 17
      src/handshake/server.rs

@ -20,7 +20,7 @@ tls = ["native-tls"]
base64 = "0.11.0" base64 = "0.11.0"
byteorder = "1.3.2" byteorder = "1.3.2"
bytes = "0.4.12" bytes = "0.4.12"
http = "0.1.19" http = "0.2"
httparse = "1.3.4" httparse = "1.3.4"
input_buffer = "0.2.0" input_buffer = "0.2.0"
log = "0.4.8" log = "0.4.8"

@ -75,15 +75,14 @@ pub fn create_response(request: &Request) -> Result<Response> {
.get("Sec-WebSocket-Key") .get("Sec-WebSocket-Key")
.ok_or_else(|| Error::Protocol("Missing Sec-WebSocket-Key".into()))?; .ok_or_else(|| Error::Protocol("Missing Sec-WebSocket-Key".into()))?;
let mut response = Response::builder(); let builder = Response::builder()
.status(StatusCode::SWITCHING_PROTOCOLS)
response.status(StatusCode::SWITCHING_PROTOCOLS); .version(request.version())
response.version(request.version()); .header("Connection", "Upgrade")
response.header("Connection", "Upgrade"); .header("Upgrade", "websocket")
response.header("Upgrade", "websocket"); .header("Sec-WebSocket-Accept", convert_key(key.as_bytes())?);
response.header("Sec-WebSocket-Accept", convert_key(key.as_bytes())?);
Ok(builder.body(())?)
Ok(response.body(())?)
} }
// Assumes that this is a valid response // Assumes that this is a valid response

Loading…
Cancel
Save