-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x/net/http2: pseudo header :protocol can not appear after regular header fields #70728
Comments
@aojea Would you be able to provide a snippet of code that could easily reproduce this condition? |
@cagedmantis I found that using the test in https://go-review.googlesource.com/c/net/+/632755 You can check that out
after a few seconds you'll find a trace in any of the logged files
If you see here https://github.com/golang/net/blob/552d8ac903a11a9fde71a88732f5b58b6b394178/http2/server.go#L2268-L2277 the :protocol pseudo header is added as a normal header and it is implemented over a map, so listing will not guarantee the order IIUIC rp.header = make(http.Header)
for _, hf := range f.RegularFields() {
rp.header.Add(sc.canonicalHeader(hf.Name), hf.Value)
}
if rp.authority == "" {
rp.authority = rp.header.Get("Host")
}
if rp.protocol != "" {
rp.header.Set(":protocol", rp.protocol)
} |
cc @tombergan |
I'm tentatively marking this as a release blocker, as #71128 points out that https://go.dev/cl/610977 is vendored into 1.24 and this sounds like a bug/regression in that CL (though I may be misunderstanding). |
Change https://go.dev/cl/641476 mentions this issue: |
HTTP/2 requires that pseudo-headers (which start with : and are used to pass information other than the regular request headers) be encoded before all regular headers. The x/net/http2 Transport's extended CONNECT support is enabled by the user setting a ":protocol" header in the Request. This header matches the pseudo-header that will be sent on the wire. Ensure that the :protocol pseudo-header is sent before any regular headers. For golang/go#70728 Change-Id: I70de7ad524ab9457d6dfb61cb3fabe3d53c6b39b Reviewed-on: https://go-review.googlesource.com/c/net/+/641476 LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Damien Neil <[email protected]> Reviewed-by: Antonio Ojea <[email protected]> Reviewed-by: Jonathan Amsterdam <[email protected]>
Change https://go.dev/cl/643256 mentions this issue: |
Change https://go.dev/cl/642398 mentions this issue: |
… before regular headers HTTP/2 requires that pseudo-headers (which start with : and are used to pass information other than the regular request headers) be encoded before all regular headers. The x/net/http2 Transport's extended CONNECT support is enabled by the user setting a ":protocol" header in the Request. This header matches the pseudo-header that will be sent on the wire. Ensure that the :protocol pseudo-header is sent before any regular headers. For golang/go#70728 Change-Id: I70de7ad524ab9457d6dfb61cb3fabe3d53c6b39b Reviewed-on: https://go-review.googlesource.com/c/net/+/641476 LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Damien Neil <[email protected]> Reviewed-by: Antonio Ojea <[email protected]> Reviewed-by: Jonathan Amsterdam <[email protected]> (cherry picked from commit 445eead) Reviewed-on: https://go-review.googlesource.com/c/net/+/643256 Auto-Submit: Dmitri Shuralyov <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
Found during the implementation of the websockets protocol over http2 on the websocket server https://go-review.googlesource.com/c/net/+/632755
/cc @neild
The text was updated successfully, but these errors were encountered: