fix: Access-Control-Request-Headers must join header names without whitespace - #236
Open
youdie006 wants to merge 1 commit into
Open
fix: Access-Control-Request-Headers must join header names without whitespace#236youdie006 wants to merge 1 commit into
youdie006 wants to merge 1 commit into
Conversation
…itespace AccessControlRequestHeaders::from_iter collected HeaderNames into the shared FlatCsv, whose FromIterator joins with a comma+space. Per the Fetch CORS-preflight spec the Access-Control-Request-Headers value is a comma-joined list with no whitespace (it does not use combine), and WPT checks this strictly, so the typed API emitted 'accept-language, date' instead of 'accept-language,date'. Give AccessControlRequestHeaders its own FromIterator<HeaderName> that joins the names with a plain ',' and wraps the result in a HeaderValue, instead of delegating to FlatCsv's ', ' joiner. The change is localized: shared FlatCsv is untouched, so other list headers (Vary, Allow, ...) keep emitting ', '. Fixes hyperium#207
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.
Fixes #207
Problem
AccessControlRequestHeaders::from_itercollectsHeaderNames into the sharedFlatCsv, whoseFromIteratorjoins with,(comma + space). But the Fetch CORS-preflight fetch spec specifies theAccess-Control-Request-Headersvalue is a,-joined list with no whitespace (it does not usecombine). The WPT testaccess-control-preflight-request-header-sorted.pychecks this strictly, and MDN's example value has no spaces. So the typed API currently emitsaccept-language, dateinstead ofaccept-language,date.@seanmonstar acknowledged this in #207 ("Well that's unfortunate (as the spec even says).") but no fix was posted.
Fix
Give
AccessControlRequestHeadersits ownFromIterator<HeaderName>that joins the names with a plain,and wraps the result in aHeaderValue, instead of delegating toFlatCsv's,joiner. The change is localized: sharedFlatCsvis left untouched, so other list headers (Vary, Allow, ...) keep emitting,.The one existing
from_itertest expectation is updated from"cache-control, if-range"to"cache-control,if-range", and a new testfrom_iter_no_space_between_namesasserts the joined value isaccept-language,date(no space).Verification
accept-language, date); with the fix it passes.cargo test --lib: all pass, no regression.cargo fmt --checkclean;cargo clippyintroduces no new warnings.This contribution was made with AI assistance.