Function hyper_tungstenite::upgrade
source · pub fn upgrade<B>(
request: impl BorrowMut<Request<B>>,
config: Option<WebSocketConfig>
) -> Result<(Response<Full<Bytes>>, HyperWebsocket), ProtocolError>
Expand description
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 is_upgrade_request
.
Alternatively you can inspect the Connection
and Upgrade
headers manually.