Skip to content

caddyhttp: normalize method names to uppercase in MatchMethod.Provision - #7832

Merged
francislavoie merged 1 commit into
caddyserver:masterfrom
yintaisha:master
Jun 21, 2026
Merged

francislavoie merged 1 commit into
caddyserver:masterfrom
yintaisha:master

Conversation

@yintaisha

Copy link
Copy Markdown
Contributor

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 post would silently never match any
request, 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:

  • _ caddy.Provisioner = (*MatchMethod)(nil)
  • _ caddy.Provisioner = (*MatchPath)(nil) (MatchPath.Provision already
    existed but lacked a corresponding guard)

A table-driven TestMethodMatcher test is added to cover uppercase,
lowercase, mixed-case, single, and multi-method scenarios.

Signed-off-by: yintaisha <yintaishan@outlook.com>
@CLAassistant

CLAassistant commented Jun 20, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@francislavoie francislavoie changed the title http: normalize method names to uppercase in MatchMethod.Provision caddyhttp: normalize method names to uppercase in MatchMethod.Provision Jun 21, 2026
@francislavoie francislavoie added this to the v2.11.5 milestone Jun 21, 2026
@francislavoie francislavoie added the bug 🐞 Something isn't working label Jun 21, 2026
@francislavoie
francislavoie enabled auto-merge (squash) June 21, 2026 08:12
@francislavoie
francislavoie merged commit f450068 into caddyserver:master Jun 21, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🐞 Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants