Skip to content

Parse extension headers with HTTP whitespace and full boundaries - #9

Open
OskarEichler wants to merge 3 commits into
faye:mainfrom
OskarEichler:codex/header-whitespace-and-boundaries
Open

Parse extension headers with HTTP whitespace and full boundaries#9
OskarEichler wants to merge 3 commits into
faye:mainfrom
OskarEichler:codex/header-whitespace-and-boundaries

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary

Accept space/tab HTTP whitespace around delimiters and require complete header/value matches. Avoid returning a partial parse from a matching line within a larger string.

Reproduction and verification

p = WebSocket::Extensions::Parser
p p.parse_header(" \text \t; mode \t= compress \t, other \t").to_a
# two offers, ext with mode=compress and other without parameters

261 focused whitespace/boundary cases pass. RFC 6455 section 9.1 uses the implied HTTP whitespace rule: https://www.rfc-editor.org/rfc/rfc6455.html#section-9.1 . Transport-level folded header lines must be unfolded before parsing. Existing broader quoted-string acceptance is deliberately unchanged. Paired small-header measurements show about 0.12 microseconds additional parsing cost (1.804 to 1.926 microseconds); this is handshake parsing, not a message-throughput speedup claim.

  • Ruby 4.0.6 through rbenv; existing current-upstream suite: 64 examples, zero failures on this isolated change.
  • The cumulative release-based candidate passes 283 focused checks (272 baseline failures → zero), 2,784 model checks, the current upstream's 64-example suite, and gem build/extraction.
  • The historical 0.1.5 suite has three Ruby keyword-versus-options-hash mock failures on both baseline and candidate. Current upstream already corrected those expectations; they were run against the candidate through an external preload without changing repository tests.
  • No new or modified tests/specs, following the consumer repository's explicit policy. Reproductions/models were run from external scratch scripts.

Breaking changes and limitations

Intentional correction: invalid unquoted newline suffixes/prefixes now raise ParseError instead of producing partial/empty results; supported space/tab formatting is accepted. Numeric coercion checks the entire decoded value.

Only local Ruby 4.0.6/macOS execution is claimed; the repository's older Ruby/JRuby matrix needs upstream CI. No production access or unrelated release upgrades.

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.

1 participant