pub fn handshake_response(req: &RequestHead) -> ResponseBuilder {
    let key = {
        let key = req.headers().get(header::SEC_WEBSOCKET_KEY).unwrap();
        proto::hash_key(key.as_ref())
    };

    Response::build(StatusCode::SWITCHING_PROTOCOLS)
        .upgrade("websocket")
        .insert_header((header::TRANSFER_ENCODING, "chunked"))
        .insert_header((
            header::SEC_WEBSOCKET_ACCEPT,
            // key is known to be header value safe ascii
            HeaderValue::from_bytes(&key).unwrap(),
        ))
        .take()
}
/// Create WebSocket handshake response.
///
/// This function returns handshake `Response`, ready to send to peer.
Create WebSocket handshake response.
This function returns handshake `Response`, ready to send to peer.
Create WebSocket handshake response . This function returns handshake ` Response ` ready to send to peer .
pub fn handshake_response(req: &RequestHead) -> ResponseBuilder {
    let key = {
        let key = req.headers().get(header::SEC_WEBSOCKET_KEY).unwrap();
        proto::hash_key(key.as_ref())
    };
    Response::build(StatusCode::SWITCHING_PROTOCOLS)
        .upgrade("websocket")
        .insert_header((header::TRANSFER_ENCODING, "chunked"))
        .insert_header((
            header::SEC_WEBSOCKET_ACCEPT,
            // key is known to be header value safe ascii
            HeaderValue::from_bytes(&key).unwrap(),
        ))
        .take()
}
pub fn handshake_response ( req : & RequestHead ) -> ResponseBuilder { let key = { let key = req . headers ( ) . get ( header :: SEC_WEBSOCKET_KEY ) . unwrap ( ) ; proto :: hash_key ( key . as_ref ( ) ) } ; Response :: build ( StatusCode :: SWITCHING_PROTOCOLS ) . upgrade ( " " ) . insert_header ( ( header :: TRANSFER_ENCODING , " " ) ) . insert_header ( ( header :: SEC_WEBSOCKET_ACCEPT , // key is known to be header value safe ascii HeaderValue :: from_bytes ( & key ) . unwrap ( ) , ) ) . take ( ) }
Create WebSocket handshake response.
Create WebSocket handshake response .
req
&RequestHead
req
&RequestHead