Repository navigation
Conversation
This branch has not been deployed
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.
A
*in the header is always mapped to the first supported value, even when the client has listed that value explicitly, e.g. withq=0:RFC 9110 §12.5.3 defines
*inAccept-Encodingas matching "any available content coding not explicitly listed in the field value".negotiator(used byaccepts/Express) agrees: it returnsbr,nullandgzipfor the three headers above. (@fastify/compressand@fastify/staticreplace*withgzipbefore callingnegotiate(), so this change does not alter their behavior. It affects direct users ofnegotiate()/Negotiator.)The fix records a
*entry's quality instead of resolving it on the spot. Once the header has been read,*is applied to the highest-priority supported value that the header did not list, using the same comparison as the explicit entries. To keep the common case cheap, explicitly listed values are only collected when the header contains a*.parse()now reports the existing early exit (first supported value atq=1), so that case still returns right away.Tests: four cases in
test/testCases.js, all failing without the change.npm test(104 tests, 100% coverage, tstyche) andnpm run lintpass. Onbenchmarks/negotiate.js, most cases are within run-to-run noise (about ±10% here), and a few are about 5–10% slower.