Skip to content

enhance(http): Support websocket upgrades#334

Merged
oschwartz10612 merged 2 commits intofosrl:devfrom
LaurenceJJones:private-http-websocket
Apr 29, 2026
Merged

enhance(http): Support websocket upgrades#334
oschwartz10612 merged 2 commits intofosrl:devfrom
LaurenceJJones:private-http-websocket

Conversation

@LaurenceJJones
Copy link
Copy Markdown
Member

@LaurenceJJones LaurenceJJones commented Apr 29, 2026

Community Contribution License Agreement

By creating this pull request, I grant the project maintainers an unlimited,
perpetual license to use, modify, and redistribute these contributions under any terms they
choose, including both the AGPLv3 and the Fossorial Commercial license terms. I
represent that I have the right to grant this license for all contributed content.

Description

Preserve optional ResponseWriter interfaces through statusCapture so httputil.ReverseProxy can hijack upgraded websocket connections for private http proxy. Add a regression test covering websocket traffic through the HTTP handler path.

How to test?

Added a golang test for regression but any private http application that uses websockets should now upgrade via the proxy.

Without exposing the funcs

INFO: 2026/04/29 07:20:27 HTTP handler: GET /socket?token=test -> http://127.0.0.1:40649
ERROR: 2026/04/29 07:20:27 HTTP handler: upstream error (GET /socket?token=test -> http://127.0.0.1:40649): can't switch protocols using non-Hijacker ResponseWriter type *netstack2.statusCapture
 --- FAIL: TestHTTPHandlerProxiesWebSocketUpgrade (0.00s)
http_handler_test.go:79: dial websocket through proxy: websocket: bad handshake
FAIL
FAIL  github.com/fosrl/newt/netstack2 0.004s
FAIL

with now succeeds

ok    github.com/fosrl/newt/netstack2 0.004s

Preserve optional ResponseWriter interfaces through statusCapture so httputil.ReverseProxy can hijack upgraded websocket connections. Add a regression test covering websocket traffic through the HTTP handler path.
@LaurenceJJones LaurenceJJones changed the title Support websocket upgrades in private HTTP proxy enhance(http): Support websocket upgrades Apr 29, 2026
Copy link
Copy Markdown
Member

@oschwartz10612 oschwartz10612 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and works!

@oschwartz10612 oschwartz10612 merged commit 5724c51 into fosrl:dev Apr 29, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants