pub async fn proxy_websocket(
req: Request<Body>,
upstream_addr: &str,
) -> Result<Response<Body>, ProxyError>Expand description
Proxy a WebSocket upgrade request to the given upstream address.
The flow:
- Open a raw TCP connection to the upstream.
- Write the HTTP upgrade request to the upstream.
- Read the upstream’s 101 response.
- Return a 101 response to the client (with the upgrade extension on the hyper side).
- Once both sides have upgraded, spawn a task that copies bytes bidirectionally until either side closes.