Repository navigation
caddyhttp: normalize method names to uppercase in MatchMethod.Provision - #7832
Merged
Merged
Conversation
Signed-off-by: yintaisha <yintaishan@outlook.com>
francislavoie
approved these changes
Jun 21, 2026
francislavoie
enabled auto-merge (squash)
June 21, 2026 08:12
This was referenced Sep 30, 2026
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.
Assistance Disclosure
HTTP method names are case-sensitive and must be uppercase per RFC 7230.
However, MatchMethod had no Provision step to normalize configured method
names, meaning a JSON config like {"method": ["get", "post"]} or a
Caddyfile snippet like
method get postwould silently never match anyrequest, since net/http always sets r.Method to uppercase.
This commit adds a Provision method to MatchMethod that uppercases all
configured method names at config load time, consistent with the pattern
used by MatchPath (which lowercases paths) and MatchHost (which normalizes
hostnames). This makes method matchers resilient to case variations in user
configs, avoiding silent mismatches.
Additionally, this commit adds the missing compile-time interface guards:
existed but lacked a corresponding guard)
A table-driven TestMethodMatcher test is added to cover uppercase,
lowercase, mixed-case, single, and multi-method scenarios.