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