Merge pull request #98 from sdroege/http-0.2

Update to http 0.2
pull/104/head
Daniel Abramov 5 years ago committed by GitHub
commit 6d8358cd19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      Cargo.toml
  2. 17
      src/handshake/server.rs

@ -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"

@ -75,15 +75,14 @@ pub fn create_response(request: &Request) -> Result<Response> {
.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

Loading…
Cancel
Save