Skip to content

Fix WebSocket client handshake failing with non-ASCII header values#532

Merged
daniel-abramov merged 1 commit intosnapview:masterfrom
BobaFetters:fix/header-value-data-error
Feb 7, 2026
Merged

Fix WebSocket client handshake failing with non-ASCII header values#532
daniel-abramov merged 1 commit intosnapview:masterfrom
BobaFetters:fix/header-value-data-error

Conversation

@BobaFetters
Copy link
Contributor

The WebSocket client handshake was incorrectly rejecting HTTP headers containing non-ASCII bytes. This occurred because generate_request() called HeaderValue::to_str() on custom headers, which fails for any non-ASCII content.

HTTP headers are defined as octets per RFC 7230, not UTF-8 strings. This fix writes header values as raw bytes, preserving their original content.

Changes

  • Replace to_str() + writeln!() with direct byte operations using extend_from_slice()
  • Add test for UTF-8 encoded header values (e.g., Montréal)
  • Add test for Latin-1 encoded header values (e.g., café)

Fixes #531

Fixing an issue where non-ASCII header values cause websocket handshake to fail.
@daniel-abramov daniel-abramov merged commit 84eaba9 into snapview:master Feb 7, 2026
7 checks passed
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.

WebSocket client handshake fails with non-ASCII header values (UTF-8 conversion error)

2 participants