Repository navigation
Conversation
pjfanning
left a comment
There was a problem hiding this comment.
Concerns:
- When no subprotocol was negotiated, a
Sec-WebSocket-Protocol/Sec-WebSocket-Extensionsheader the application added itself is now silently removed at render time, and one the app deliberately removed is put back. Code that callshandleMessages(flow)and then addsSec-WebSocket-Protocolby hand would lose it, and browsers fail the connection in that case. Is overriding the application wanted, or would removing duplicateSec-WebSocket-Acceptheaders be enough? Either way it needs a release note. - Passing the generated headers via the handler Flow's stream
Attributesfeels hacky; a field on the internal header class would be more direct. - The existing "for echoing user handler" test in
WebSocketServerSpecis rewritten from an exact wire assertion to a byte loop checking three fields, droppingUpgrade/Connectionchecks. Could the original stay and the new scenario be a separate test? - The
WebSocketDirectivesSpectests callWebSocketUpgradeResponseHeaders.forRenderingdirectly rather than going through the renderer.
Motivation: The server generates the acceptance value for a WebSocket upgrade. Application response decorations should not break that required handshake field or override application-managed headers. Modification: Store the generated acceptance in the internal WebSocket switch header, not Flow attributes. The HTTP/1 renderer emits that field once for the WebSocket upgrade and preserves all other headers. Add a behavior release note and direct renderer coverage. Result: Application-selected subprotocols and extensions are unchanged. Other protocol upgrades use the existing rendering path. No public Java or Scala API signatures change. Tests: JDK 17 on Scala 2.13.18 and 3.3.9: five focused positive renderer and WebSocket checks each. The new restoration assertion fails on main as expected. Scoped formatting and JVM signatures of the existing internal marker and companion were checked. References: RFC 6455 sections 4.2.2 and 11.3.3; PJ's review on apache#1608.
0cffc8e to
71c5685
Compare
pjfanning
left a comment
There was a problem hiding this comment.
Thanks, this is much narrower now: only Sec-WebSocket-Accept is restored, application changes to the other headers are left alone, the existing echo test is untouched and the new tests go through the renderer. One thing left:
UpgradeToOtherProtocolResponseHeader changes from a final case class to a sealed case class so that WebSocketUpgradeResponseHeader can extend it. Extending a case class brings the usual problems: equals/hashCode only look at handler, so the subclass compares equal to a plain UpgradeToOtherProtocolResponseHeader with the same handler, and copy returns the base class and loses accept. Nothing depends on that today, but an optional field on the existing class (accept: Option[...] or OptionVal), or a common trait with two final classes, would avoid it.
Motivation: Application response decoration can remove the server-generated WebSocket acceptance header. Preserve it without overriding application negotiations. Modification: Retain the generated acceptance in a final WebSocket marker. Share the existing completion-close handling with the final generic upgrade marker without deriving one case class from another. Restrict acceptance handling to server WebSocket switches. Add focused renderer tests and a release note. Result: The response emits the generated acceptance once. Other response headers, generic upgrades and the completion-close behavior are unchanged. References: RFC 6455 sections 4.2.2 and 11.3.3; review of apache#1608.
71c5685 to
73e58bb
Compare
Motivation
The server must keep the framework-generated WebSocket Accept metadata without taking control of headers that applications select.
Modification
Track only the generated
Sec-WebSocket-Acceptmetadata in an immutable internal marker, not in Flow attributes. Leave application-selected protocol, extensions, and other ordinary headers alone. Keep the existing echo test unchanged, add separate response-renderer assertions, and document the behavior in the release notes.Result
The framework maintains the generated Accept metadata while applications retain control of ordinary negotiation and response headers. Public method signatures are unchanged.
Tests
JDK 17: all five focused tests passed on each of Scala 2.13.18 and Scala 3.3.9 (5/5 each), using the exact changed source with cached compiled support. The reviewed JVM method descriptors still match. This is not a full CI or MiMa run.
References
None - Informed by Netty 4.2's outbound response construction test and RFC 6455 §4.2.2 / §11.3.2–§11.3.4. Uses Pekko HTTP's own upgrade flow; no Netty code copied.