Skip to content

Method::new is case-insensitive, so a lowercase verb is classified idempotent while the origin sees something else #1451

Closed

Description

@FlorentinDUBOIS

Method::new uses compare_no_case, so a request line reading get /path HTTP/1.1 produces Method::Get. RFC 9110 §9.1 makes the method token case-sensitive, and the origin receives the original get bytes — so sozu and the backend can disagree about what method a request carries.

Pre-existing and long-harmless. #1442 made it load-bearing: is_idempotent now gates whether a request may be replayed on a fresh backend, so a lowercase extension verb that sozu maps to an idempotent variant becomes replayable while the origin may treat it as something else entirely.

A note recording the gap was added at is_idempotent's doc comment in #1442. This issue is the fix.

Why the narrow fix is not the cheap one

The obvious scoping — "only make the replay decision case-sensitive" — does not work. context.method is already normalised by the time any replay decision runs, and the raw token is gone; recovering it would mean carrying a new field on HttpContext purely for this check.

Making Method::new case-sensitive is the correct fix, and it changes behaviour repo-wide: routing, metrics labels and access-log output all read from the same normalised value. That is a behaviour change to the request path, not a local correction, which is why it is an issue rather than a patch.

What the fix has to establish

  • What a non-conforming peer currently gets, and what it would get after. A client sending get today is routed and logged as GET. After, it becomes a Custom method — confirm what that does to routing, to http.status.* label cardinality, and to the access log, and say so explicitly rather than assuming "it just works".
  • Whether any fixture, e2e test or doc example relies on the lenient behaviour. Grep for lowercase method tokens in e2e/, lib/src/protocol/, fuzz/ and doc/ with no file-type filter, and disposition every hit.
  • Metric cardinality. If Custom methods reach a metrics label, a peer can mint labels by varying case. Check before changing, because the lenient behaviour may currently be what collapses them.

Proof

A regression test seen red: a request line with a lowercase idempotent verb must not be classified idempotent. Revert the fix, show it failing, restore it, show it passing, and paste both.

Then run the full e2e suite — this touches the request path, and the changeset's blast radius is wider than its diff.

Explicitly not asked for

Do not add a case-insensitive fallback or an alias table to preserve current behaviour for known verbs. That reintroduces the divergence this issue exists to remove, in a form that is harder to see.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions