#801·goproxy

WebSocket through HTTPS MITM drops data the client sent right after the upgrade request

Author: mark-bradshawCreated Sep 3, 2026Updated Sep 5, 2026

When a client sends its first WebSocket frame immediately after the GET ... Upgrade: websocket request (in the same write, before the 101 comes back), the MITM path loses that frame.

The request is parsed with a buffered reader. Anything the reader pulled in past the end of the HTTP request stays in that buffer. After the 101, the proxy starts copying bytes directly from the raw connection, so the buffered bytes are never forwarded to the origin. The client waits for a reply that never comes.

We hit this with a CLI tool behind goproxy v1.8.2, and it is still present in v1.9.0 (https.go, the proxyWebsocket(ctx, wsConn, client) call).

Reproduce: put a WebSocket echo server behind the MITM proxy. Have a raw TLS client send the upgrade request and one masked text frame in a single write, then read. With v1.9.0 the read times out. If the frame is sent in a second write after the 101 arrives, it works.

We carry a small local patch that reads from the parser's buffered reader instead of the raw connection when starting the relay, which fixes it. Happy to send a PR if that approach sounds right.