Repository navigation
Conversation
`MethodRouter::merge` concatenated the two `Allow` header values without de-duplication, while the per-router builder path (`append_allow_header`) already avoids duplicates. Because `get` registers both `GET` and `HEAD`, merging a `get` route with a separately built `head` route produced `Allow: GET,HEAD,HEAD`. Route the merge through the same de-duplicating helper so each method is listed once. Add a regression test covering the merge case.
zelinewang
force-pushed
the
fix/method-router-merge-duplicate-allow-header
branch
from
July 15, 2026 00:21
af91ccd to
64c9fa0
Compare
mladedav
requested changes
Jul 15, 2026
mladedav
left a comment
Collaborator
There was a problem hiding this comment.
I have it said it seems weird that a codex bot gave thumbs up to the PR, out of curiosity, do you happen to know why? Did you use it to open the PR?
Contributor
Author
|
fixed all four. that +1 is just the codex github app on my account, didn't ask it to do anything. and I do use AI in my workflow for finding and drafting fixes, everything here was verified locally before the PR went up, it works pretty fast and with good quality as long as thoroughly tested |
mladedav
approved these changes
Jul 16, 2026
dihannahdi
added a commit
to dihannahdi/axum
that referenced
this pull request
Jul 16, 2026
The only conflict was the CHANGELOG. tokio-rs#3836 landed an Allow-header fix in the same Unreleased block, so I kept both fixed entries. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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.
Motivation
getregisters a handler for bothGETandHEAD, so agetroute'sAllowheader value is
GET,HEAD. When twoMethodRouters are merged, theirAllowheader values are joined together. The join did not remove duplicates, so
merging a
getroute with a separately builtheadroute produced anAllowheader of
GET,HEAD,HEAD:This is reachable through
Router::mergeas well, whenever the merged routershave a
getroute on one side and an explicitheadroute on the other for thesame path. The builder path already guards against this:
append_allow_headerskips a method that is already present, which is why
get(..).head(..)on asingle router correctly yields
GET,HEAD. Only the merge path was missing thesame guard.
Solution
Route the
Bytes+Bytescase ofAllowHeader::mergethrough the existingappend_allow_headerhelper, one method at a time, so the merged value reusesthe same de-duplication the builder already performs.
append_allow_headeronlycopies the bytes of the method it is given, so its parameter is relaxed from
&'static strto&strto accept the method names split out of the otherheader value.
Behavior is otherwise unchanged:
None/Skipstates merge as before, andmerging routers with disjoint methods still concatenates them in order (the
existing
allow_header_when_mergingtest, which expectsPUT,PATCH,GET,HEAD,still passes). A regression test covers merging a
getroute with a separateheadroute and asserts theAllowheader isGET,HEAD.