Ciro Spaciari
c90c0e69cb
feat(websocket): add HTTP/HTTPS proxy support (#25614)
## Summary
Add `proxy` option to WebSocket constructor for connecting through HTTP
CONNECT proxies.
### Features
- Support for `ws://` and `wss://` through HTTP proxies
- Support for `ws://` and `wss://` through HTTPS proxies (with
`rejectUnauthorized: false`)
- Proxy authentication via URL credentials (Basic auth)
- Custom proxy headers support
- Full TLS options (`ca`, `cert`, `key`, etc.) for target connections
using `SSLConfig.fromJS`
### API
```javascript
// String format
new WebSocket("wss://example.com", { proxy: "http://proxy:8080" })
// With credentials
new WebSocket("wss://example.com", { proxy: "http://user:pass@proxy:8080" })
// Object format with custom headers
new WebSocket("wss://example.com", {
proxy: { url: "http://proxy:8080", headers: { "X-Custom": "value" } }
})
// HTTPS proxy
new WebSocket("ws://example.com", {
proxy: "https://proxy:8443",
tls: { rejectUnauthorized: false }
})
```
### Implementation
| File | Changes |
|------|---------|
| `WebSocketUpgradeClient.zig` | Proxy state machine and CONNECT
handling |
| `WebSocketProxyTunnel.zig` | **New** - TLS tunnel inside CONNECT for
wss:// through HTTP proxy |
| `JSWebSocket.cpp` | Parse proxy option and TLS options using
`SSLConfig.fromJS` |
| `WebSocket.cpp` | Pass proxy parameters to Zig, handle HTTPS proxy
socket selection |
| `bun.d.ts` | Add `proxy` and full TLS options to WebSocket types |
### Supported Scenarios
| Scenario | Status |
|----------|--------|
| ws:// through HTTP proxy | ✅ Working |
| wss:// through HTTP proxy | ✅ Working (TLS tunnel) |
| ws:// through HTTPS proxy | ✅ Working (with `rejectUnauthorized:
false`) |
| wss:// through HTTPS proxy | ✅ Working (with `rejectUnauthorized:
false`) |
| Proxy authentication (Basic) | ✅ Working |
| Custom proxy headers | ✅ Working |
| Custom CA for HTTPS proxy | ✅ Working |
## Test plan
- [x] API tests verify proxy option is accepted in various formats
- [x] Functional tests with local HTTP CONNECT proxy server
- [x] Proxy authentication tests (Basic auth)
- [x] HTTPS proxy tests with `rejectUnauthorized: false`
- [x] Error handling tests (auth failures, wrong credentials)
Run tests: `bun test test/js/web/websocket/websocket-proxy.test.ts`
## Changelog
- Added `proxy` option to `WebSocket` constructor for HTTP/HTTPS proxy
support
- Added full TLS options (`ca`, `cert`, `key`, `passphrase`, etc.) to
`WebSocket` constructor
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-01-08 16:21:34 -08:00
..
2025-12-19 23:18:21 -08:00
2025-12-11 17:44:14 -08:00
2026-01-08 11:32:08 -08:00
2025-12-15 12:51:13 -08:00
2026-01-07 23:23:27 -08:00
2026-01-08 16:21:34 -08:00
2026-01-08 15:05:41 -08:00
2026-01-07 22:46:51 -08:00
2025-12-25 14:00:58 -08:00
2026-01-06 23:05:01 +00:00
2025-11-10 14:38:26 -08:00
2025-12-21 17:12:42 -08:00
2026-01-02 04:52:47 -08:00
2025-11-10 14:38:26 -08:00
2025-11-23 01:41:17 -08:00
2026-01-08 16:21:34 -08:00
2025-12-05 18:32:51 -08:00
2025-12-18 18:04:28 -08:00
2025-12-16 14:29:39 -08:00
2025-12-23 22:24:18 -08:00
2026-01-08 16:21:34 -08:00
2025-11-10 14:38:26 -08:00
2025-10-03 17:10:28 -07:00
2025-12-15 19:50:11 -08:00
2025-11-24 20:16:03 -08:00
2025-11-10 14:38:26 -08:00
2025-11-10 14:38:26 -08:00
2025-12-25 23:49:23 -08:00
2026-01-05 15:04:20 -08:00
2025-11-10 14:38:26 -08:00
2025-11-20 20:56:02 -08:00
2025-12-27 17:25:52 -08:00
2025-11-10 14:38:26 -08:00
2026-01-08 16:21:34 -08:00
2025-12-10 16:17:57 -08:00
2025-11-10 14:38:26 -08:00
2025-11-10 14:38:26 -08:00
2025-12-22 12:07:24 -08:00
2025-12-01 21:59:11 -08:00
2025-12-25 14:00:58 -08:00
2025-11-10 14:38:26 -08:00
2025-11-10 14:38:26 -08:00
2025-10-04 02:17:55 -07:00
2025-10-31 19:50:55 -07:00
2025-11-26 00:02:43 -08:00
2025-11-05 15:28:28 -08:00
2025-11-10 14:38:26 -08:00
2025-10-23 23:08:08 -07:00
2026-01-05 10:21:49 -08:00
2025-11-10 14:38:26 -08:00
2025-11-10 14:38:26 -08:00
2025-12-23 22:24:18 -08:00
2025-12-11 17:44:14 -08:00
2025-11-25 11:06:24 -08:00
2025-11-10 14:38:26 -08:00
2025-11-10 19:58:02 -08:00
2026-01-07 12:33:21 -08:00
2026-01-07 22:46:51 -08:00
2025-09-26 15:19:45 -07:00
2025-11-18 10:49:21 -08:00
2025-10-29 19:29:04 -07:00
2025-11-03 22:20:07 -08:00
2025-11-10 14:38:26 -08:00
2025-11-20 20:56:02 -08:00
2025-11-20 20:56:02 -08:00
2025-09-26 22:21:00 -07:00
2025-11-10 14:38:26 -08:00
2025-11-10 14:38:26 -08:00
2025-11-10 14:38:26 -08:00
2025-12-19 23:17:29 -08:00
2026-01-07 16:09:49 -08:00
2025-11-20 23:37:31 -08:00
2025-11-10 14:38:26 -08:00
2025-11-18 10:49:21 -08:00
2025-10-23 23:08:08 -07:00
2025-11-10 14:38:26 -08:00
2026-01-07 16:09:49 -08:00
2025-08-23 06:55:30 -07:00
2025-10-04 00:31:47 -07:00
2025-11-10 14:38:26 -08:00
2025-10-02 14:11:29 -07:00
2025-11-10 14:38:26 -08:00
2025-11-10 14:38:26 -08:00
2025-09-09 20:41:10 -07:00
2026-01-08 16:21:34 -08:00
2026-01-07 22:46:51 -08:00
2025-12-17 19:56:25 -08:00
2025-08-23 06:55:30 -07:00
2025-11-10 14:38:26 -08:00
2025-11-10 14:38:26 -08:00
2025-12-21 17:12:42 -08:00
2025-11-10 14:38:26 -08:00
2025-12-21 17:12:42 -08:00
2025-10-23 23:08:08 -07:00
2025-12-21 17:12:42 -08:00
2025-12-06 16:37:09 -08:00
2025-11-10 14:38:26 -08:00
2025-11-10 14:38:26 -08:00
2025-11-10 14:38:26 -08:00
2025-10-18 18:14:01 -07:00
2025-11-10 14:38:26 -08:00
2025-09-14 04:14:48 -07:00
2026-01-07 22:46:51 -08:00
2025-11-30 23:11:33 -08:00
2026-01-07 16:09:49 -08:00
2025-11-10 14:38:26 -08:00
2025-09-30 00:10:15 -07:00
2025-12-06 16:37:09 -08:00
2025-12-01 21:59:11 -08:00
2025-11-10 14:38:26 -08:00
2025-11-13 19:29:16 -08:00
2025-09-26 15:15:58 -07:00
2025-11-10 14:38:26 -08:00
2025-11-15 16:36:15 -08:00
2025-09-26 22:21:00 -07:00
2025-12-11 17:44:14 -08:00
2025-09-03 15:40:44 -07:00
2025-09-22 19:28:26 -07:00
2025-11-10 14:38:26 -08:00
2026-01-07 16:09:49 -08:00
2025-11-10 14:38:26 -08:00
2025-11-28 22:56:28 -08:00
2025-12-15 19:50:11 -08:00
2025-12-15 19:50:11 -08:00
2025-11-10 14:38:26 -08:00
2025-12-19 23:18:21 -08:00
2025-09-03 15:40:44 -07:00
2025-11-10 14:38:26 -08:00
2025-12-21 17:12:42 -08:00
2025-10-03 17:10:28 -07:00
2025-12-15 13:21:41 -08:00
2025-11-10 14:38:26 -08:00
2025-11-18 10:49:21 -08:00
2025-11-30 23:11:33 -08:00
2025-11-10 14:38:26 -08:00
2025-12-18 21:42:14 -08:00