Skip to content

test: cover WebSocket Close reason split across reads - #1865

Open
He-Pin wants to merge 1 commit into
apache:mainfrom
He-Pin:test/ws-close-reason-split
Open

He-Pin wants to merge 1 commit into
apache:mainfrom
He-Pin:test/ws-close-reason-split

Conversation

@He-Pin

@He-Pin He-Pin commented Nov 29, 2026

Copy link
Copy Markdown
Member

Motivation

A transport read may end inside a multibyte character in the reason of a valid WebSocket Close frame.

Modification

Render a normal Close with status 1000 using the production frame renderer, split the resulting bytes inside the first multibyte character, and pass the two reads through the existing decoder. No production changes.

Result

The decoder reports status 1000 and the original UTF-8 reason.

Tests

  • The targeted WebSocketCompletionCloseSpec case passed on Scala 2.13.18 (JDK 17).
  • Scoped header and Scala formatting checks passed.

References

@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.

The test itself looks fine. One nit, not blocking: it only drives FrameEventRenderer -> FrameEventParser -> FrameHandler and has nothing to do with completion-close behaviour, so it would sit better in FramingSpec (or MessageSpec) than as a new group at the top of WebSocketCompletionCloseSpec.

Motivation:
A transport read can end inside the UTF-8 reason of a valid Close frame.

Modification:
Use the stock frame renderer and split its output inside the first multibyte character before feeding the decoder.

Result:
The decoder reports normal status 1000 and the original reason without changing production code.

Tests:
Targeted WebSocketCompletionCloseSpec case passed on Scala 2.13.18 (JDK 17). Scoped formatting and header checks passed.

References:
RFC 6455 §5.5.1.
@He-Pin
He-Pin force-pushed the test/ws-close-reason-split branch from 2c553da to fa72eb6 Compare November 29, 2026 14:38
@He-Pin
He-Pin requested a review from pjfanning November 29, 2026 14:40
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