Skip to content

http.request.proto is wonky for HTTP/2 and HTTP/3 (there’s no such thing as “HTTP/2.0” or “HTTP/3.0”) #7734

Closed

Description

@chris-morgan

Issue Details

respond `{{placeholder "http.request.proto"}}`
templates

Fetch it over the different protocols, e.g. with curl --http1.0 &c., and observe the values.

Protocol http.request.proto
HTTP/1.0 HTTP/1.0
HTTP/1.1 HTTP/1.1
HTTP/2 HTTP/2.0
HTTP/3 HTTP/3.0

“HTTP/2.0” and “HTTP/3.0” are incorrect: there are no such versions of HTTP, they’re HTTP/2 and HTTP/3.

Ideally (in my mind) the values would be fixed. But at the very least, the documentation should mention the possible values.

Assistance Disclosure

AI not used

If AI was used, describe the extent to which it was used.

No response

Activity

  1. WeidiDeng commented on May 17, 2026

    @WeidiDeng
    Member

    This two values actually comes from upstream,

    For http2,

    https://github.com/golang/net/blob/f8651996b24ba47d89dd9eb97fd47758e6d1886f/http2/server.go#L2218

    For http3,

    https://github.com/quic-go/quic-go/blob/a72e083d99ad7b72708a210ec09aefcb0f73f2e1/http3/headers.go#L254

    I agree that's unexpected for anything not familiar with go, but even stdlib can't parse valid http version like HTTP/2 🤷 .

    Also, for http3 it's used to be HTTP/3, but it broke caddy, and it was patched to return HTTP/3.0.

    But sure, caddy has a long way to go regarding documentation.

  2. added
    documentation 📚
    upstream ⬆️
    on May 17, 2026
  3. chris-morgan commented on May 17, 2026

    @chris-morgan
    Author

    I wonder how people actually use http.request.proto. Feels icky for it to be exposing incorrect implementation details from Go’s net/http, but it seems quite plausible that such a variable is mostly being used by other things with similar wrongness.

    Thanks for the background, I’d found a part of the source stuff but not all (I don’t use Go). It’s nice to learn history and reasons and such.

    For me, I guess I can map it myself, something like this in Caddyfile:

    map {http.request.proto} {proto_name} {
        HTTP/2.0             HTTP/2
        HTTP/3.0             HTTP/3
        default              {http.request.proto}
    }
  4. steadytao commented on May 17, 2026

    @steadytao
    Member

    Chris is right that the spec-style names are HTTP/2 and HTTP/3 but I do not think we should change {http.request.proto} in place. This is exposing Go’s http.Request.Proto, which uses the HTTP/<major>.<minor> shape and quic-go intentionally changed HTTP/3 from HTTP/3 to HTTP/3.0 in quic-go/quic-go@990b1fe to fix #4819, as mentioned by Weidi. That matters because this value can flow into CGI/FastCGI-style SERVER_PROTOCOL expectations.

    I think the right fix is likely documentation for {http.request.proto} stating that it reflects Go’s protocol string and can be HTTP/2.0 or HTTP/3.0. If we want spec-style protocol names for templates/placeholders, I would add a separate normalised placeholder rather than changing this one and risking compatibility regressions with with Go/CGI-compatible protocol version syntax.

  5. francislavoie commented on May 18, 2026

    @francislavoie
    Member

    We could add something like http.request.proto_standard or something (name is open for discussion) instead of changing the existing placeholder

  6. steadytao commented on May 18, 2026

    @steadytao
    Member

    The shape makes sense to me. But I am not fully sold on http.request.proto_standard as the final name, mostly because “standard” is a bit ambiguous here, {http.request.proto} already follows Go/CGI-compatible protocol-version syntax while the new placeholder would be the spec-style protocol token so technically {http.request.proto} follows a standard itself.

    Maybe {http.request.proto.name} is clearer? Then the distinction is:

    • {http.request.proto}= Go http.Request.Proto / CGI-compatible protocol version, e.g. HTTP/2.0, HTTP/3.0
    • {http.request.proto.name}= spec-style protocol name, e.g. HTTP/2, HTTP/3

    I think the placeholder name we land with should make the distinction obvious enough that users do not expect one to replace the other.

  7. francislavoie commented on May 18, 2026

    @francislavoie
    Member

    I think proto_name makes sense. More of a sibling than nesting or property-of

  8. added a commit that references this issue on May 30, 2026
    b67ff2f
  9. added a commit that references this issue on Jun 4, 2026
    915793f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentation 📚upstream ⬆️

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions