Repository navigation
Accept Connection token lists in WebSocket client handshakes - #1428
Merged
Merged
Conversation
pjfanning
reviewed
Nov 17, 2026
pjfanning
left a comment
Member
There was a problem hiding this comment.
Thanks, this looks right. Reusing Connection.hasUpgrade gives the case-insensitive token match RFC 6455 §4.1 asks for, and matches what the server side already does in Handshake. The negative cases (xupgrade, upgraded) show it's a token match, not a substring match. A couple of points:
- Follow-up: repeated
Connectionlines.HttpMessageParsermerges the tokens of repeatedConnectionheader lines only into its internalchvalue (used for keep-alive/close). The message's header list keeps just the first line. SoConnection: keep-alivefollowed by a separateConnection: Upgradeline is still rejected by_.header[Connection]. The server-side check has the same limitation. You already call this out of scope in the description, which is fine, but it might be worth a follow-up issue, since split list fields are valid HTTP. - Docs. The two new sentences in
websocket-support.mddescribe standard handshake validation that users don't control. I'd leave them out.
He-Pin
added a commit
to He-Pin/incubator-pekko-http
that referenced
this pull request
Nov 17, 2026
Motivation: The guide need not repeat standard upgrade token validation rules. Modification: Remove the two statements describing client handshake token checks. Result: The guide stays focused on API usage; implementation and tests are unchanged. Tests: Not run - docs only. References: Refs apache#1428 and PJ's review.
He-Pin
added a commit
to He-Pin/incubator-pekko-http
that referenced
this pull request
Nov 17, 2026
Motivation: Whole-field matching rejects valid responses whose Connection field contains Upgrade alongside other tokens. Modification: Use Connection.hasUpgrade and test token positions, mixed case and nonmatching tokens. Keep the usage guide focused on the public API. Result: The client accepts valid token lists within one field while retaining the other handshake checks. Repeated field handling is unchanged. Tests: The existing runtime patch passed 184 WebSocket package tests and 23 focused client tests. The follow-up is docs-only. No new runtime tests or CI query for this squash. References: Refs apache#1428 and RFC 6455 section 4.1.
He-Pin
force-pushed
the
fix/websocket-connection-tokens
branch
from
November 17, 2026 15:12
1b765c5 to
672b809
Compare
Motivation: Whole-field matching rejects valid responses whose Connection field contains Upgrade alongside other tokens. Modification: Use Connection.hasUpgrade and test token positions, mixed case and nonmatching tokens. Keep the usage guide focused on the public API. Result: The client accepts valid token lists within one field while retaining the other handshake checks. Repeated field handling is unchanged. Tests: The existing runtime patch passed 184 WebSocket package tests and 23 focused client tests. The follow-up is docs-only. No new runtime tests or CI query for this squash. References: Refs apache#1428 and RFC 6455 section 4.1.
Member
pjfanning
force-pushed
the
fix/websocket-connection-tokens
branch
from
November 18, 2026 21:04
672b809 to
6ab384b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The client currently compares the entire
Connectionresponse field toupgrade. This rejects a valid WebSocket handshake such asConnection: keep-alive, Upgrade, although RFC 6455 section 4.1 requires a case-insensitive token match, not an exact field-value match.Modification
Connection.hasUpgradewhen validating the client's opening handshake.Result
The client accepts valid single-field
Connectiontoken lists without weakening the remaining handshake checks. No public API or visibility changes are made.This change is deliberately scoped to token matching within one field. Handling of repeated
Connectionresponse fields in the HTTP parser is unchanged.Tests
WebSocketClientSpecrerun: 23/23 passed, including the additional middle-token case.http-core/mimaReportBinaryIssues, cross-ScalaheaderCheckAll, and scoped scalafmt checks passed.docs/paradoxpassed (existing duplicate-anchor warnings).validatePullRequestand CI were not run.References
RFC 6455 section 4.1, client response validation step 3.