Skip to content

Commit

Permalink
Merge pull request snapview#98 from sdroege/http-0.2
Browse files Browse the repository at this point in the history
Update to http 0.2
  • Loading branch information
daniel-abramov authored Dec 10, 2019
2 parents 1da9614 + c3aff4a commit 6d8358c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
17 changes: 8 additions & 9 deletions src/handshake/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6d8358c

Please sign in to comment.