Skip to content

Fix: compare the WebSocket Upgrade header case-insensitively - #51

Merged
Garados007 merged 1 commit into
Garados007:mainfrom
S0CloseYetS0Far:fix/websocket-upgrade-case
Oct 4, 2026
Merged

Garados007 merged 1 commit into
Garados007:mainfrom
S0CloseYetS0Far:fix/websocket-upgrade-case

Conversation

@S0CloseYetS0Far

Copy link
Copy Markdown
Contributor

Fixes #48

RFC 6455 section 4.2.1 says the Upgrade value is case-insensitive, but WebSocketService.CanWorkWith compared it with == "websocket". A client sending Upgrade: WebSocket never got the handshake and fell through to normal HTTP handling (usually a 404).

Change: compare with string.Equals(..., StringComparison.OrdinalIgnoreCase), matching the existing Connection check on the same line.

Tests (TestWebSocketService):

  • CanWorkWith accepts websocket, WebSocket and WEBSOCKET (the latter two fail on main)
  • CanWorkWith still rejects a different upgrade (h2c)

Full suite passes on net8.0 and net10.0.

🤖 Generated with Claude Code

RFC 6455 section 4.2.1 says the Upgrade value is case-insensitive. A client
sending `Upgrade: WebSocket` failed the `== "websocket"` check and fell
through to normal HTTP handling.

Fixes Garados007#48

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@S0CloseYetS0Far

Copy link
Copy Markdown
Contributor Author

:)

@Garados007
Garados007 merged commit 6ca20ad into Garados007:main Oct 4, 2026
1 check 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.

WebSocket upgrade check is case-sensitive for Upgrade

2 participants