Function hyper_tungstenite::upgrade[][src]

pub fn upgrade(
    request: Request<Body>,
    config: Option<WebSocketConfig>
) -> Result<(Response<Body>, HyperWebsocket)>

Try to upgrade a received hyper::Request to a websocket connection.

The function returns a HTTP response and a future that resolves to the websocket stream. The response body MUST be sent to the client before the future can be resolved.

This functions checks Sec-WebSocket-Key and Sec-WebSocket-Version headers. It does not inspect the Origin, Sec-WebSocket-Protocol or Sec-WebSocket-Extensions headers. You can inspect the headers manually before calling this function, and modify the response headers appropriately.

This function also does not look at the Connection or Upgrade headers. To check if a request is a websocket upgrade request, you can use upgrade_requested. Alternatively you can inspect the Connection and Upgrade headers manually.