Repository navigation
ledger: negotiate Accept in-tree - #278
Merged
Merged
Conversation
rvolosatovs
force-pushed
the
roman/ledger/accept
branch
from
October 21, 2026 15:26
99f337f to
12847dd
Compare
rvolosatovs
force-pushed
the
roman/ledger/accept
branch
5 times, most recently
from
October 21, 2026 16:08
87e199e to
e73f3b2
Compare
Replace the `headers-accept` dependency, pinned to an unmerged upstream PR for its `q`-insensitive parameter matching, with a small RFC 9110 section 12.5.1 implementation. `headers-core` is dropped along with it. Media ranges are parsed directly from the field bytes following the RFC 9110 grammar: HTTP tokens, empty list elements and parameters, quoted-string values with quoted-pairs and `obs-text`, and no whitespace around `=`. Only exact `*` subtypes are wildcards, so `*/*+json` and `*/wasm` are literal ranges that match nothing. Type, subtype and parameter names compare case-insensitively, quoted and token parameter values are equivalent, and `charset` values compare case-insensitively. Any parameter named `q` is the weight regardless of its position, and a range with more than one weight is rejected. The most specific media range matching an available type determines its quality, ranges with `q=0` exclude it. Ties are broken by specificity, header order and server preference. Negotiation now always yields a media type, defaulting to the first available one without an `Accept` header, which simplifies the handlers. An `Accept` header listing no media ranges, such as an empty one, is treated as absent, as Spring, ASP.NET Core and Gin do, instead of rejecting every representation with 406. `AcceptHeaderError::Decoding` is replaced by `Malformed`, `Quality` and `QualityDuplicate`. Unit tests in the `accept` module cover the negotiation. Assisted-by: anthropic:claude-opus-5-5 Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
rvolosatovs
force-pushed
the
roman/ledger/accept
branch
from
October 21, 2026 16:11
e73f3b2 to
5269353
Compare
rvolosatovs
marked this pull request as ready for review
October 21, 2026 17:35
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.
Last commit in https://github.com/maxcountryman/headers-accept repo is 8 months old and the crate is not spec-compliant at the moment. The functionality we need is really simple, so just implement it in-tree and drop the dependency