permessage-deflate: make client/server_max_window_bits optional in the offer#599
Open
mikkel-kaj wants to merge 1 commit into
Open
permessage-deflate: make client/server_max_window_bits optional in the offer#599mikkel-kaj wants to merge 1 commit into
mikkel-kaj wants to merge 1 commit into
Conversation
…deflate offer permessage-deflate always appended "; server_max_window_bits=15; client_max_window_bits=15" to the handshake header. 15 is the RFC 7692 default window size, so those parameters convey nothing, and some servers and gateways reject a client offer that carries them. Add a sendClientServerMaxWindowBits flag on WebSocketPerMessageDeflateOptions (default true, so existing behavior is unchanged) that gates emitting the two parameters. Set it to false to send a bare "permessage-deflate" offer. Also initialize the flag in the header-parsing constructor, which previously left it unset. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Connecting as a client to a server that rejects a
permessage-deflateoffer carryingclient_max_window_bits/server_max_window_bitsfails, and there is no way to leave those parameters out.generateHeader()unconditionally appends; server_max_window_bits=15; client_max_window_bits=15. 15 is the default window size in RFC 7692 (section 7.1.2), so advertising=15conveys nothing the peer would not already assume — the parameters only carry meaning when you want a window smaller than 15 to save memory. Some servers and gateways are strict about the extension parameters they accept and reject an offer that includes them, and the library gives no way to suppress them.Fix
Add a
sendClientServerMaxWindowBitsflag onWebSocketPerMessageDeflateOptionsthat gates emitting the two parameters.Defaults to
true, so the generated header is identical for anyone who does not set it.Set it to
falseto send a barepermessage-deflateoffer:The new parameter is appended at the end of the constructor, so existing positional calls are unaffected.
The header-parsing constructor now initializes the flag as well; it was left unset before.
Verification
Built the library (zlib backend) and exercised
generateHeader()both ways:The default output matches the current header exactly; with the flag off the two parameters are gone. The existing
per-message-deflate-codectest still passes.