Skip to content

Fix WebSocket proxy implementation issues#33

Closed
Copilot wants to merge 4 commits intofeature/simpleproxy-websocket-upgradefrom
copilot/sub-pr-32
Closed

Fix WebSocket proxy implementation issues#33
Copilot wants to merge 4 commits intofeature/simpleproxy-websocket-upgradefrom
copilot/sub-pr-32

Conversation

Copy link

Copilot AI commented Jan 16, 2026

Addresses code review feedback on #32. The original implementation had critical bugs preventing WebSocket upgrades and lacked TLS support for wss:// connections.

Critical Fixes

HTTP version formatting - Request line was malformed using Debug format:

// Before: outputs "GET / Http11\r\n" (invalid)
format!("{} {} {:?}\r\n", req.method(), path, req.version())

// After: outputs "GET / HTTP/1.1\r\n" (valid)
format!("{} {} {}\r\n", req.method(), path, version_str)

TLS/WSS support - Added secure WebSocket handling:

  • Detect wss:// scheme via is_schema_secure()
  • Establish TLS handshake before WebSocket upgrade
  • Updated tunnel_websocket_forward to accept EitherTlsStream

Header parsing - Fixed response header parsing to handle colons in values using find(':') instead of split_once(':')

Code Quality

  • Extracted is_websocket_upgrade() helper to eliminate duplication
  • Removed unused send_request_no_cache function
  • Improved error handling with explicit validation instead of unwrap_or("")
  • Corrected HTTP/2 and HTTP/3 version strings per RFC specs

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits January 16, 2026 04:49
- Fix HTTP version formatting (was using Debug format)
- Improve error handling for malformed HTTP responses
- Add helper function to detect WebSocket upgrades (reduces duplication)
- Improve header parsing robustness (handle colons in values)
- Remove unused send_request_no_cache function
- Remove redundant underscore assignment in tunnel function

Co-authored-by: arloor <21768987+arloor@users.noreply.github.com>
- Check URI scheme to determine if TLS is needed
- Wrap TCP connection with TLS for wss:// URIs
- Update tunnel function to handle EitherTlsStream
- Add proper TLS handshake logging

Co-authored-by: arloor <21768987+arloor@users.noreply.github.com>
- Correct HTTP/2 and HTTP/3 version strings per RFC specs
- Revert header end detection to explicit CRLF/LF check

Co-authored-by: arloor <21768987+arloor@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on websocket proxy support PR Fix WebSocket proxy implementation issues Jan 16, 2026
Copilot AI requested a review from arloor January 16, 2026 04:58
@arloor arloor closed this Jan 16, 2026
@arloor arloor deleted the copilot/sub-pr-32 branch January 16, 2026 11:44
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