golang.org/x/crypto v0.30.0 h1:RwoQn3GkWiMkzlX562cLB7OxWvjH1L8xutO2WoJcRoY=
golang.org/x/crypto v0.30.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
-golang.org/x/net v0.32.1-0.20241206180132-552d8ac903a1 h1:+Yk1FZ5E+/ewA0nOO/HRYs9E4yeqpGOShuSAdzCNNoQ=
-golang.org/x/net v0.32.1-0.20241206180132-552d8ac903a1/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs=
+golang.org/x/net v0.32.1-0.20250121202134-9a960c88dd98 h1:36bTiCRO7f/J3t+LumnLTJDXqxsp1x6Q7754SsRD9u4=
+golang.org/x/net v0.32.1-0.20250121202134-9a960c88dd98/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
}
var (
- http2VerboseLogs bool
- http2logFrameWrites bool
- http2logFrameReads bool
- http2inTests bool
- http2disableExtendedConnectProtocol bool
+ http2VerboseLogs bool
+ http2logFrameWrites bool
+ http2logFrameReads bool
+ http2inTests bool
+
+ // Enabling extended CONNECT by causes browsers to attempt to use
+ // WebSockets-over-HTTP/2. This results in problems when the server's websocket
+ // package doesn't support extended CONNECT.
+ //
+ // Disable extended CONNECT by default for now.
+ //
+ // Issue #71128.
+ http2disableExtendedConnectProtocol = true
)
func init() {
http2logFrameWrites = true
http2logFrameReads = true
}
- if strings.Contains(e, "http2xconnect=0") {
- http2disableExtendedConnectProtocol = true
+ if strings.Contains(e, "http2xconnect=1") {
+ http2disableExtendedConnectProtocol = false
}
}
var http2errNilRequestURL = errors.New("http2: Request.URI is nil")
-func http2isNormalConnect(req *Request) bool {
- return req.Method == "CONNECT" && req.Header.Get(":protocol") == ""
-}
-
// requires cc.wmu be held.
func (cc *http2ClientConn) encodeHeaders(req *Request, addGzipHeader bool, trailers string, contentLength int64) ([]byte, error) {
cc.hbuf.Reset()
return nil, errors.New("http2: invalid Host header")
}
+ // isNormalConnect is true if this is a non-extended CONNECT request.
+ isNormalConnect := false
+ protocol := req.Header.Get(":protocol")
+ if req.Method == "CONNECT" && protocol == "" {
+ isNormalConnect = true
+ } else if protocol != "" && req.Method != "CONNECT" {
+ return nil, errors.New("http2: invalid :protocol header in non-CONNECT request")
+ }
+
var path string
- if !http2isNormalConnect(req) {
+ if !isNormalConnect {
path = req.URL.RequestURI()
if !http2validPseudoPath(path) {
orig := path
m = MethodGet
}
f(":method", m)
- if !http2isNormalConnect(req) {
+ if !isNormalConnect {
f(":path", path)
f(":scheme", req.URL.Scheme)
}
+ if protocol != "" {
+ f(":protocol", protocol)
+ }
if trailers != "" {
f("trailer", trailers)
}
}
}
continue
+ } else if k == ":protocol" {
+ // :protocol pseudo-header was already sent above.
+ continue
}
for _, v := range vv {