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