Repository navigation
caddyhttp: add {http.request.proto_name} placeholder for spec-compliant protocol names - #7782
Conversation
steadytao
left a comment
There was a problem hiding this comment.
I think this should also update the placeholder table in modules/caddyhttp/app.go since the original issue was at least a documentation gap. Please document both placeholders there {http.request.proto} as Go’s raw http.Request.Proto value which may be HTTP/2.0 or HTTP/3.0 and {http.request.proto_name} as the spec-style protocol name.
|
@francislavoie @chris-morgan Bumping this your way for your opinion. |
|
This sounds good to me. I presume docs changes would follow, wherever they go. (Oh, just saw the “needs docs” label.) |
…nt protocol names
{http.request.proto} exposes Go's raw http.Request.Proto field which
returns HTTP/2.0 and HTTP/3.0 for HTTP/2 and HTTP/3 respectively.
These strings are non-standard since the specs define them as HTTP/2
and HTTP/3.
To preserve backward compat (especially CGI/FastCGI expectations),
{http.request.proto} is kept as-is. A new {http.request.proto_name}
placeholder is introduced that normalises the version string to the
spec-defined form:
HTTP/2.0 -> HTTP/2
HTTP/3.0 -> HTTP/3
all others returned unchanged
Closes caddyserver#7734
70e3c50 to
b67ff2f
Compare
|
@steadytao I have updated the PR to address your feedback. I added documentation for both placeholders in |
steadytao
left a comment
There was a problem hiding this comment.
LGTM.
The app.go update should cover the generated HTTP app placeholder docs via moduledoc so I do not think a separate website PR is needed for the placeholder table itself unless we want additional explanatory prose elsewhere.
|
Just want a review from Francis as he was involved directly as well then I am happy to merge. Also, @chris-morgan, docs are updated dynamically using moduledoc (albeit when Matt remembers to do so) via source comments and module metadata. So this PR would update the placeholder table and I can't see anywhere else that likely needs the additional prose from a quick scan through. |
|
I've updated the PR based on the feedback.
Tested locally and everything looks good! |
Before:
The {http.request.proto}\ placeholder returns the Go standard library's raw protocol representation (e.g., \HTTP/2.0\ or \HTTP/3.0). This diverges from standard web specifications which define these as \HTTP/2\ and \HTTP/3.
After:
This PR adds a new {http.request.proto_name}\ placeholder.
It utilizes a new helper function \GetProtoName(proto string)\ which maps raw Go protocol strings (\HTTP/2.0, \HTTP/3.0) to their spec-compliant names (\HTTP/2, \HTTP/3). Standard HTTP/1.x protocols remain unaffected.
Additionally, this PR updates the placeholder documentation in \�pp.go\ to clarify the distinction between {http.request.proto}\ (the raw Go string) and {http.request.proto_name}\ (the spec-defined name), and uses \httptest.NewRequest\ for proper error handling in the test cases.
Closes #7734
Assistance Disclosure
The root cause analysis, code modification, and documentation updates were performed with the assistance of Antigravity by Google Deepmind.