Skip to content

fix: preserve generated WebSocket request singleton headers - #1606

Merged
He-Pin merged 1 commit into
apache:mainfrom
He-Pin:fix/ws-generated-request-singletons
Nov 26, 2026
Merged

He-Pin merged 1 commit into
apache:mainfrom
He-Pin:fix/ws-generated-request-singletons

Conversation

@He-Pin

@He-Pin He-Pin commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Motivation

The client generates the opening handshake key and protocol version. Supplying either field through extra headers could send the field twice, even though RFC 6455 requires each to appear only once.

Modification

Ignore caller-supplied WebSocket key and version fields when constructing the opening request, preserving the generated fields and other extra headers. Document their ordinary public usage for Scala and Java callers. This revision clarifies the documentation and minimizes test imports; it does not change the prior revision’s production code or add logging.

Result

The request keeps the generated key used to validate the server's handshake and sends version 13 once. Other extra headers retain their order and values, including list-valued negotiation fields and Connection options. No generic HTTP header rendering changes.

Tests

The focused normal WebSocket client checks passed with the exact changed source on Scala 2.13.18 and 3.3.9. The targeted Paradox render passed. No full CI run.

References

RFC 6455 §11.3.1 and §11.3.5. Informed by Netty 4.2's outbound client handshake test; narrower by design to preserve valid Pekko HTTP request extras.

@pjfanning pjfanning left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fix looks correct. Nits:

  • Caller Sec-WebSocket-Key/Sec-WebSocket-Version headers are now dropped silently; consider a debug/warn log, and a line in the client-side WebSocket docs (only scaladoc was updated).
  • The import reorder in WebSocketClientSpec is unrelated churn.

@He-Pin
He-Pin force-pushed the fix/ws-generated-request-singletons branch from af7d127 to d83a973 Compare November 26, 2026 12:22
@He-Pin
He-Pin requested a review from pjfanning November 26, 2026 12:23

@pjfanning pjfanning left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

Motivation: The WebSocket client generates its own opening key and
protocol version. Caller extras must not add duplicate singleton fields.

Modification: Keep the generated key and version when building the
request. Explain the boundary between application-provided headers and
generated fields in the client guide and both request APIs. Keep the
test's existing import order except for required additions.

Result: Caller-provided key and version fields are not sent, while
ordinary application headers and negotiated options are preserved.
No public signatures or generic header handling changed.

References: RFC 6455 sections 11.3.1 and 11.3.5; Netty 4.2's outbound
handshake builder test informed the original coverage.
@He-Pin
He-Pin force-pushed the fix/ws-generated-request-singletons branch from d83a973 to a73156d Compare November 26, 2026 20:20
@He-Pin
He-Pin merged commit 450947c into apache:main Nov 26, 2026
6 checks passed
@He-Pin
He-Pin deleted the fix/ws-generated-request-singletons branch November 26, 2026 20:35
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