mirror of
https://github.com/containers/podman.git
synced 2025-07-04 18:27:33 +08:00
fix(deps): update module golang.org/x/net to v0.36.0 [security]
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This commit is contained in:
2
go.mod
2
go.mod
@ -72,7 +72,7 @@ require (
|
|||||||
github.com/vishvananda/netlink v1.3.1-0.20250221194427-0af32151e72b
|
github.com/vishvananda/netlink v1.3.1-0.20250221194427-0af32151e72b
|
||||||
go.etcd.io/bbolt v1.3.11
|
go.etcd.io/bbolt v1.3.11
|
||||||
golang.org/x/crypto v0.36.0
|
golang.org/x/crypto v0.36.0
|
||||||
golang.org/x/net v0.35.0
|
golang.org/x/net v0.36.0
|
||||||
golang.org/x/sync v0.12.0
|
golang.org/x/sync v0.12.0
|
||||||
golang.org/x/sys v0.31.0
|
golang.org/x/sys v0.31.0
|
||||||
golang.org/x/term v0.30.0
|
golang.org/x/term v0.30.0
|
||||||
|
4
go.sum
4
go.sum
@ -619,8 +619,8 @@ golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
|||||||
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
|
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
|
||||||
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||||
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
|
golang.org/x/net v0.36.0 h1:vWF2fRbw4qslQsQzgFqZff+BItCvGFQqKzKIzx1rmoA=
|
||||||
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
|
golang.org/x/net v0.36.0/go.mod h1:bFmbeoIPfrw4sMHNhb4J9f6+tPziuGjq7Jk/38fxi1I=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.26.0 h1:afQXWNNaeC4nvZ0Ed9XvCCzXM6UHJG7iCg0W4fPqSBE=
|
golang.org/x/oauth2 v0.26.0 h1:afQXWNNaeC4nvZ0Ed9XvCCzXM6UHJG7iCg0W4fPqSBE=
|
||||||
golang.org/x/oauth2 v0.26.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
|
golang.org/x/oauth2 v0.26.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
|
||||||
|
121
vendor/golang.org/x/net/http2/server.go
generated
vendored
121
vendor/golang.org/x/net/http2/server.go
generated
vendored
@ -2233,25 +2233,25 @@ func (sc *serverConn) newStream(id, pusherID uint32, state streamState) *stream
|
|||||||
func (sc *serverConn) newWriterAndRequest(st *stream, f *MetaHeadersFrame) (*responseWriter, *http.Request, error) {
|
func (sc *serverConn) newWriterAndRequest(st *stream, f *MetaHeadersFrame) (*responseWriter, *http.Request, error) {
|
||||||
sc.serveG.check()
|
sc.serveG.check()
|
||||||
|
|
||||||
rp := requestParam{
|
rp := httpcommon.ServerRequestParam{
|
||||||
method: f.PseudoValue("method"),
|
Method: f.PseudoValue("method"),
|
||||||
scheme: f.PseudoValue("scheme"),
|
Scheme: f.PseudoValue("scheme"),
|
||||||
authority: f.PseudoValue("authority"),
|
Authority: f.PseudoValue("authority"),
|
||||||
path: f.PseudoValue("path"),
|
Path: f.PseudoValue("path"),
|
||||||
protocol: f.PseudoValue("protocol"),
|
Protocol: f.PseudoValue("protocol"),
|
||||||
}
|
}
|
||||||
|
|
||||||
// extended connect is disabled, so we should not see :protocol
|
// extended connect is disabled, so we should not see :protocol
|
||||||
if disableExtendedConnectProtocol && rp.protocol != "" {
|
if disableExtendedConnectProtocol && rp.Protocol != "" {
|
||||||
return nil, nil, sc.countError("bad_connect", streamError(f.StreamID, ErrCodeProtocol))
|
return nil, nil, sc.countError("bad_connect", streamError(f.StreamID, ErrCodeProtocol))
|
||||||
}
|
}
|
||||||
|
|
||||||
isConnect := rp.method == "CONNECT"
|
isConnect := rp.Method == "CONNECT"
|
||||||
if isConnect {
|
if isConnect {
|
||||||
if rp.protocol == "" && (rp.path != "" || rp.scheme != "" || rp.authority == "") {
|
if rp.Protocol == "" && (rp.Path != "" || rp.Scheme != "" || rp.Authority == "") {
|
||||||
return nil, nil, sc.countError("bad_connect", streamError(f.StreamID, ErrCodeProtocol))
|
return nil, nil, sc.countError("bad_connect", streamError(f.StreamID, ErrCodeProtocol))
|
||||||
}
|
}
|
||||||
} else if rp.method == "" || rp.path == "" || (rp.scheme != "https" && rp.scheme != "http") {
|
} else if rp.Method == "" || rp.Path == "" || (rp.Scheme != "https" && rp.Scheme != "http") {
|
||||||
// See 8.1.2.6 Malformed Requests and Responses:
|
// See 8.1.2.6 Malformed Requests and Responses:
|
||||||
//
|
//
|
||||||
// Malformed requests or responses that are detected
|
// Malformed requests or responses that are detected
|
||||||
@ -2265,15 +2265,16 @@ func (sc *serverConn) newWriterAndRequest(st *stream, f *MetaHeadersFrame) (*res
|
|||||||
return nil, nil, sc.countError("bad_path_method", streamError(f.StreamID, ErrCodeProtocol))
|
return nil, nil, sc.countError("bad_path_method", streamError(f.StreamID, ErrCodeProtocol))
|
||||||
}
|
}
|
||||||
|
|
||||||
rp.header = make(http.Header)
|
header := make(http.Header)
|
||||||
|
rp.Header = header
|
||||||
for _, hf := range f.RegularFields() {
|
for _, hf := range f.RegularFields() {
|
||||||
rp.header.Add(sc.canonicalHeader(hf.Name), hf.Value)
|
header.Add(sc.canonicalHeader(hf.Name), hf.Value)
|
||||||
}
|
}
|
||||||
if rp.authority == "" {
|
if rp.Authority == "" {
|
||||||
rp.authority = rp.header.Get("Host")
|
rp.Authority = header.Get("Host")
|
||||||
}
|
}
|
||||||
if rp.protocol != "" {
|
if rp.Protocol != "" {
|
||||||
rp.header.Set(":protocol", rp.protocol)
|
header.Set(":protocol", rp.Protocol)
|
||||||
}
|
}
|
||||||
|
|
||||||
rw, req, err := sc.newWriterAndRequestNoBody(st, rp)
|
rw, req, err := sc.newWriterAndRequestNoBody(st, rp)
|
||||||
@ -2282,7 +2283,7 @@ func (sc *serverConn) newWriterAndRequest(st *stream, f *MetaHeadersFrame) (*res
|
|||||||
}
|
}
|
||||||
bodyOpen := !f.StreamEnded()
|
bodyOpen := !f.StreamEnded()
|
||||||
if bodyOpen {
|
if bodyOpen {
|
||||||
if vv, ok := rp.header["Content-Length"]; ok {
|
if vv, ok := rp.Header["Content-Length"]; ok {
|
||||||
if cl, err := strconv.ParseUint(vv[0], 10, 63); err == nil {
|
if cl, err := strconv.ParseUint(vv[0], 10, 63); err == nil {
|
||||||
req.ContentLength = int64(cl)
|
req.ContentLength = int64(cl)
|
||||||
} else {
|
} else {
|
||||||
@ -2298,84 +2299,38 @@ func (sc *serverConn) newWriterAndRequest(st *stream, f *MetaHeadersFrame) (*res
|
|||||||
return rw, req, nil
|
return rw, req, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type requestParam struct {
|
func (sc *serverConn) newWriterAndRequestNoBody(st *stream, rp httpcommon.ServerRequestParam) (*responseWriter, *http.Request, error) {
|
||||||
method string
|
|
||||||
scheme, authority, path string
|
|
||||||
protocol string
|
|
||||||
header http.Header
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sc *serverConn) newWriterAndRequestNoBody(st *stream, rp requestParam) (*responseWriter, *http.Request, error) {
|
|
||||||
sc.serveG.check()
|
sc.serveG.check()
|
||||||
|
|
||||||
var tlsState *tls.ConnectionState // nil if not scheme https
|
var tlsState *tls.ConnectionState // nil if not scheme https
|
||||||
if rp.scheme == "https" {
|
if rp.Scheme == "https" {
|
||||||
tlsState = sc.tlsState
|
tlsState = sc.tlsState
|
||||||
}
|
}
|
||||||
|
|
||||||
needsContinue := httpguts.HeaderValuesContainsToken(rp.header["Expect"], "100-continue")
|
res := httpcommon.NewServerRequest(rp)
|
||||||
if needsContinue {
|
if res.InvalidReason != "" {
|
||||||
rp.header.Del("Expect")
|
return nil, nil, sc.countError(res.InvalidReason, streamError(st.id, ErrCodeProtocol))
|
||||||
}
|
|
||||||
// Merge Cookie headers into one "; "-delimited value.
|
|
||||||
if cookies := rp.header["Cookie"]; len(cookies) > 1 {
|
|
||||||
rp.header.Set("Cookie", strings.Join(cookies, "; "))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setup Trailers
|
|
||||||
var trailer http.Header
|
|
||||||
for _, v := range rp.header["Trailer"] {
|
|
||||||
for _, key := range strings.Split(v, ",") {
|
|
||||||
key = http.CanonicalHeaderKey(textproto.TrimString(key))
|
|
||||||
switch key {
|
|
||||||
case "Transfer-Encoding", "Trailer", "Content-Length":
|
|
||||||
// Bogus. (copy of http1 rules)
|
|
||||||
// Ignore.
|
|
||||||
default:
|
|
||||||
if trailer == nil {
|
|
||||||
trailer = make(http.Header)
|
|
||||||
}
|
|
||||||
trailer[key] = nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delete(rp.header, "Trailer")
|
|
||||||
|
|
||||||
var url_ *url.URL
|
|
||||||
var requestURI string
|
|
||||||
if rp.method == "CONNECT" && rp.protocol == "" {
|
|
||||||
url_ = &url.URL{Host: rp.authority}
|
|
||||||
requestURI = rp.authority // mimic HTTP/1 server behavior
|
|
||||||
} else {
|
|
||||||
var err error
|
|
||||||
url_, err = url.ParseRequestURI(rp.path)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, sc.countError("bad_path", streamError(st.id, ErrCodeProtocol))
|
|
||||||
}
|
|
||||||
requestURI = rp.path
|
|
||||||
}
|
}
|
||||||
|
|
||||||
body := &requestBody{
|
body := &requestBody{
|
||||||
conn: sc,
|
conn: sc,
|
||||||
stream: st,
|
stream: st,
|
||||||
needsContinue: needsContinue,
|
needsContinue: res.NeedsContinue,
|
||||||
}
|
}
|
||||||
req := &http.Request{
|
req := (&http.Request{
|
||||||
Method: rp.method,
|
Method: rp.Method,
|
||||||
URL: url_,
|
URL: res.URL,
|
||||||
RemoteAddr: sc.remoteAddrStr,
|
RemoteAddr: sc.remoteAddrStr,
|
||||||
Header: rp.header,
|
Header: rp.Header,
|
||||||
RequestURI: requestURI,
|
RequestURI: res.RequestURI,
|
||||||
Proto: "HTTP/2.0",
|
Proto: "HTTP/2.0",
|
||||||
ProtoMajor: 2,
|
ProtoMajor: 2,
|
||||||
ProtoMinor: 0,
|
ProtoMinor: 0,
|
||||||
TLS: tlsState,
|
TLS: tlsState,
|
||||||
Host: rp.authority,
|
Host: rp.Authority,
|
||||||
Body: body,
|
Body: body,
|
||||||
Trailer: trailer,
|
Trailer: res.Trailer,
|
||||||
}
|
}).WithContext(st.ctx)
|
||||||
req = req.WithContext(st.ctx)
|
|
||||||
|
|
||||||
rw := sc.newResponseWriter(st, req)
|
rw := sc.newResponseWriter(st, req)
|
||||||
return rw, req, nil
|
return rw, req, nil
|
||||||
}
|
}
|
||||||
@ -3270,12 +3225,12 @@ func (sc *serverConn) startPush(msg *startPushRequest) {
|
|||||||
// we start in "half closed (remote)" for simplicity.
|
// we start in "half closed (remote)" for simplicity.
|
||||||
// See further comments at the definition of stateHalfClosedRemote.
|
// See further comments at the definition of stateHalfClosedRemote.
|
||||||
promised := sc.newStream(promisedID, msg.parent.id, stateHalfClosedRemote)
|
promised := sc.newStream(promisedID, msg.parent.id, stateHalfClosedRemote)
|
||||||
rw, req, err := sc.newWriterAndRequestNoBody(promised, requestParam{
|
rw, req, err := sc.newWriterAndRequestNoBody(promised, httpcommon.ServerRequestParam{
|
||||||
method: msg.method,
|
Method: msg.method,
|
||||||
scheme: msg.url.Scheme,
|
Scheme: msg.url.Scheme,
|
||||||
authority: msg.url.Host,
|
Authority: msg.url.Host,
|
||||||
path: msg.url.RequestURI(),
|
Path: msg.url.RequestURI(),
|
||||||
header: cloneHeader(msg.header), // clone since handler runs concurrently with writing the PUSH_PROMISE
|
Header: cloneHeader(msg.header), // clone since handler runs concurrently with writing the PUSH_PROMISE
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Should not happen, since we've already validated msg.url.
|
// Should not happen, since we've already validated msg.url.
|
||||||
|
52
vendor/golang.org/x/net/http2/transport.go
generated
vendored
52
vendor/golang.org/x/net/http2/transport.go
generated
vendored
@ -1286,6 +1286,19 @@ func (cc *ClientConn) responseHeaderTimeout() time.Duration {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// actualContentLength returns a sanitized version of
|
||||||
|
// req.ContentLength, where 0 actually means zero (not unknown) and -1
|
||||||
|
// means unknown.
|
||||||
|
func actualContentLength(req *http.Request) int64 {
|
||||||
|
if req.Body == nil || req.Body == http.NoBody {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
if req.ContentLength != 0 {
|
||||||
|
return req.ContentLength
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
func (cc *ClientConn) decrStreamReservations() {
|
func (cc *ClientConn) decrStreamReservations() {
|
||||||
cc.mu.Lock()
|
cc.mu.Lock()
|
||||||
defer cc.mu.Unlock()
|
defer cc.mu.Unlock()
|
||||||
@ -1310,7 +1323,7 @@ func (cc *ClientConn) roundTrip(req *http.Request, streamf func(*clientStream))
|
|||||||
reqCancel: req.Cancel,
|
reqCancel: req.Cancel,
|
||||||
isHead: req.Method == "HEAD",
|
isHead: req.Method == "HEAD",
|
||||||
reqBody: req.Body,
|
reqBody: req.Body,
|
||||||
reqBodyContentLength: httpcommon.ActualContentLength(req),
|
reqBodyContentLength: actualContentLength(req),
|
||||||
trace: httptrace.ContextClientTrace(ctx),
|
trace: httptrace.ContextClientTrace(ctx),
|
||||||
peerClosed: make(chan struct{}),
|
peerClosed: make(chan struct{}),
|
||||||
abort: make(chan struct{}),
|
abort: make(chan struct{}),
|
||||||
@ -1318,7 +1331,7 @@ func (cc *ClientConn) roundTrip(req *http.Request, streamf func(*clientStream))
|
|||||||
donec: make(chan struct{}),
|
donec: make(chan struct{}),
|
||||||
}
|
}
|
||||||
|
|
||||||
cs.requestedGzip = httpcommon.IsRequestGzip(req, cc.t.disableCompression())
|
cs.requestedGzip = httpcommon.IsRequestGzip(req.Method, req.Header, cc.t.disableCompression())
|
||||||
|
|
||||||
go cs.doRequest(req, streamf)
|
go cs.doRequest(req, streamf)
|
||||||
|
|
||||||
@ -1349,7 +1362,7 @@ func (cc *ClientConn) roundTrip(req *http.Request, streamf func(*clientStream))
|
|||||||
}
|
}
|
||||||
res.Request = req
|
res.Request = req
|
||||||
res.TLS = cc.tlsState
|
res.TLS = cc.tlsState
|
||||||
if res.Body == noBody && httpcommon.ActualContentLength(req) == 0 {
|
if res.Body == noBody && actualContentLength(req) == 0 {
|
||||||
// If there isn't a request or response body still being
|
// If there isn't a request or response body still being
|
||||||
// written, then wait for the stream to be closed before
|
// written, then wait for the stream to be closed before
|
||||||
// RoundTrip returns.
|
// RoundTrip returns.
|
||||||
@ -1596,12 +1609,7 @@ func (cs *clientStream) encodeAndWriteHeaders(req *http.Request) error {
|
|||||||
// sent by writeRequestBody below, along with any Trailers,
|
// sent by writeRequestBody below, along with any Trailers,
|
||||||
// again in form HEADERS{1}, CONTINUATION{0,})
|
// again in form HEADERS{1}, CONTINUATION{0,})
|
||||||
cc.hbuf.Reset()
|
cc.hbuf.Reset()
|
||||||
res, err := httpcommon.EncodeHeaders(httpcommon.EncodeHeadersParam{
|
res, err := encodeRequestHeaders(req, cs.requestedGzip, cc.peerMaxHeaderListSize, func(name, value string) {
|
||||||
Request: req,
|
|
||||||
AddGzipHeader: cs.requestedGzip,
|
|
||||||
PeerMaxHeaderListSize: cc.peerMaxHeaderListSize,
|
|
||||||
DefaultUserAgent: defaultUserAgent,
|
|
||||||
}, func(name, value string) {
|
|
||||||
cc.writeHeader(name, value)
|
cc.writeHeader(name, value)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1617,6 +1625,22 @@ func (cs *clientStream) encodeAndWriteHeaders(req *http.Request) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func encodeRequestHeaders(req *http.Request, addGzipHeader bool, peerMaxHeaderListSize uint64, headerf func(name, value string)) (httpcommon.EncodeHeadersResult, error) {
|
||||||
|
return httpcommon.EncodeHeaders(req.Context(), httpcommon.EncodeHeadersParam{
|
||||||
|
Request: httpcommon.Request{
|
||||||
|
Header: req.Header,
|
||||||
|
Trailer: req.Trailer,
|
||||||
|
URL: req.URL,
|
||||||
|
Host: req.Host,
|
||||||
|
Method: req.Method,
|
||||||
|
ActualContentLength: actualContentLength(req),
|
||||||
|
},
|
||||||
|
AddGzipHeader: addGzipHeader,
|
||||||
|
PeerMaxHeaderListSize: peerMaxHeaderListSize,
|
||||||
|
DefaultUserAgent: defaultUserAgent,
|
||||||
|
}, headerf)
|
||||||
|
}
|
||||||
|
|
||||||
// cleanupWriteRequest performs post-request tasks.
|
// cleanupWriteRequest performs post-request tasks.
|
||||||
//
|
//
|
||||||
// If err (the result of writeRequest) is non-nil and the stream is not closed,
|
// If err (the result of writeRequest) is non-nil and the stream is not closed,
|
||||||
@ -2186,6 +2210,13 @@ func (rl *clientConnReadLoop) cleanup() {
|
|||||||
}
|
}
|
||||||
cc.cond.Broadcast()
|
cc.cond.Broadcast()
|
||||||
cc.mu.Unlock()
|
cc.mu.Unlock()
|
||||||
|
|
||||||
|
if !cc.seenSettings {
|
||||||
|
// If we have a pending request that wants extended CONNECT,
|
||||||
|
// let it continue and fail with the connection error.
|
||||||
|
cc.extendedConnectAllowed = true
|
||||||
|
close(cc.seenSettingsChan)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// countReadFrameError calls Transport.CountError with a string
|
// countReadFrameError calls Transport.CountError with a string
|
||||||
@ -2278,9 +2309,6 @@ func (rl *clientConnReadLoop) run() error {
|
|||||||
if VerboseLogs {
|
if VerboseLogs {
|
||||||
cc.vlogf("http2: Transport conn %p received error from processing frame %v: %v", cc, summarizeFrame(f), err)
|
cc.vlogf("http2: Transport conn %p received error from processing frame %v: %v", cc, summarizeFrame(f), err)
|
||||||
}
|
}
|
||||||
if !cc.seenSettings {
|
|
||||||
close(cc.seenSettingsChan)
|
|
||||||
}
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
6
vendor/golang.org/x/net/internal/httpcommon/headermap.go
generated
vendored
6
vendor/golang.org/x/net/internal/httpcommon/headermap.go
generated
vendored
@ -5,7 +5,7 @@
|
|||||||
package httpcommon
|
package httpcommon
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/textproto"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ func buildCommonHeaderMaps() {
|
|||||||
commonLowerHeader = make(map[string]string, len(common))
|
commonLowerHeader = make(map[string]string, len(common))
|
||||||
commonCanonHeader = make(map[string]string, len(common))
|
commonCanonHeader = make(map[string]string, len(common))
|
||||||
for _, v := range common {
|
for _, v := range common {
|
||||||
chk := http.CanonicalHeaderKey(v)
|
chk := textproto.CanonicalMIMEHeaderKey(v)
|
||||||
commonLowerHeader[chk] = v
|
commonLowerHeader[chk] = v
|
||||||
commonCanonHeader[v] = chk
|
commonCanonHeader[v] = chk
|
||||||
}
|
}
|
||||||
@ -104,7 +104,7 @@ func CanonicalHeader(v string) string {
|
|||||||
if s, ok := commonCanonHeader[v]; ok {
|
if s, ok := commonCanonHeader[v]; ok {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
return http.CanonicalHeaderKey(v)
|
return textproto.CanonicalMIMEHeaderKey(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CachedCanonicalHeader returns the canonical form of a well-known header name.
|
// CachedCanonicalHeader returns the canonical form of a well-known header name.
|
||||||
|
166
vendor/golang.org/x/net/internal/httpcommon/request.go
generated
vendored
166
vendor/golang.org/x/net/internal/httpcommon/request.go
generated
vendored
@ -5,10 +5,12 @@
|
|||||||
package httpcommon
|
package httpcommon
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
|
||||||
"net/http/httptrace"
|
"net/http/httptrace"
|
||||||
|
"net/textproto"
|
||||||
|
"net/url"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -21,9 +23,21 @@ var (
|
|||||||
ErrRequestHeaderListSize = errors.New("request header list larger than peer's advertised limit")
|
ErrRequestHeaderListSize = errors.New("request header list larger than peer's advertised limit")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Request is a subset of http.Request.
|
||||||
|
// It'd be simpler to pass an *http.Request, of course, but we can't depend on net/http
|
||||||
|
// without creating a dependency cycle.
|
||||||
|
type Request struct {
|
||||||
|
URL *url.URL
|
||||||
|
Method string
|
||||||
|
Host string
|
||||||
|
Header map[string][]string
|
||||||
|
Trailer map[string][]string
|
||||||
|
ActualContentLength int64 // 0 means 0, -1 means unknown
|
||||||
|
}
|
||||||
|
|
||||||
// EncodeHeadersParam is parameters to EncodeHeaders.
|
// EncodeHeadersParam is parameters to EncodeHeaders.
|
||||||
type EncodeHeadersParam struct {
|
type EncodeHeadersParam struct {
|
||||||
Request *http.Request
|
Request Request
|
||||||
|
|
||||||
// AddGzipHeader indicates that an "accept-encoding: gzip" header should be
|
// AddGzipHeader indicates that an "accept-encoding: gzip" header should be
|
||||||
// added to the request.
|
// added to the request.
|
||||||
@ -47,11 +61,11 @@ type EncodeHeadersResult struct {
|
|||||||
// It validates a request and calls headerf with each pseudo-header and header
|
// It validates a request and calls headerf with each pseudo-header and header
|
||||||
// for the request.
|
// for the request.
|
||||||
// The headerf function is called with the validated, canonicalized header name.
|
// The headerf function is called with the validated, canonicalized header name.
|
||||||
func EncodeHeaders(param EncodeHeadersParam, headerf func(name, value string)) (res EncodeHeadersResult, _ error) {
|
func EncodeHeaders(ctx context.Context, param EncodeHeadersParam, headerf func(name, value string)) (res EncodeHeadersResult, _ error) {
|
||||||
req := param.Request
|
req := param.Request
|
||||||
|
|
||||||
// Check for invalid connection-level headers.
|
// Check for invalid connection-level headers.
|
||||||
if err := checkConnHeaders(req); err != nil {
|
if err := checkConnHeaders(req.Header); err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +87,10 @@ func EncodeHeaders(param EncodeHeadersParam, headerf func(name, value string)) (
|
|||||||
|
|
||||||
// isNormalConnect is true if this is a non-extended CONNECT request.
|
// isNormalConnect is true if this is a non-extended CONNECT request.
|
||||||
isNormalConnect := false
|
isNormalConnect := false
|
||||||
protocol := req.Header.Get(":protocol")
|
var protocol string
|
||||||
|
if vv := req.Header[":protocol"]; len(vv) > 0 {
|
||||||
|
protocol = vv[0]
|
||||||
|
}
|
||||||
if req.Method == "CONNECT" && protocol == "" {
|
if req.Method == "CONNECT" && protocol == "" {
|
||||||
isNormalConnect = true
|
isNormalConnect = true
|
||||||
} else if protocol != "" && req.Method != "CONNECT" {
|
} else if protocol != "" && req.Method != "CONNECT" {
|
||||||
@ -107,9 +124,7 @@ func EncodeHeaders(param EncodeHeadersParam, headerf func(name, value string)) (
|
|||||||
return res, fmt.Errorf("invalid HTTP trailer %s", err)
|
return res, fmt.Errorf("invalid HTTP trailer %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
contentLength := ActualContentLength(req)
|
trailers, err := commaSeparatedTrailers(req.Trailer)
|
||||||
|
|
||||||
trailers, err := commaSeparatedTrailers(req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
@ -123,7 +138,7 @@ func EncodeHeaders(param EncodeHeadersParam, headerf func(name, value string)) (
|
|||||||
f(":authority", host)
|
f(":authority", host)
|
||||||
m := req.Method
|
m := req.Method
|
||||||
if m == "" {
|
if m == "" {
|
||||||
m = http.MethodGet
|
m = "GET"
|
||||||
}
|
}
|
||||||
f(":method", m)
|
f(":method", m)
|
||||||
if !isNormalConnect {
|
if !isNormalConnect {
|
||||||
@ -198,8 +213,8 @@ func EncodeHeaders(param EncodeHeadersParam, headerf func(name, value string)) (
|
|||||||
f(k, v)
|
f(k, v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if shouldSendReqContentLength(req.Method, contentLength) {
|
if shouldSendReqContentLength(req.Method, req.ActualContentLength) {
|
||||||
f("content-length", strconv.FormatInt(contentLength, 10))
|
f("content-length", strconv.FormatInt(req.ActualContentLength, 10))
|
||||||
}
|
}
|
||||||
if param.AddGzipHeader {
|
if param.AddGzipHeader {
|
||||||
f("accept-encoding", "gzip")
|
f("accept-encoding", "gzip")
|
||||||
@ -225,7 +240,7 @@ func EncodeHeaders(param EncodeHeadersParam, headerf func(name, value string)) (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
trace := httptrace.ContextClientTrace(req.Context())
|
trace := httptrace.ContextClientTrace(ctx)
|
||||||
|
|
||||||
// Header list size is ok. Write the headers.
|
// Header list size is ok. Write the headers.
|
||||||
enumerateHeaders(func(name, value string) {
|
enumerateHeaders(func(name, value string) {
|
||||||
@ -243,19 +258,19 @@ func EncodeHeaders(param EncodeHeadersParam, headerf func(name, value string)) (
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
res.HasBody = contentLength != 0
|
res.HasBody = req.ActualContentLength != 0
|
||||||
res.HasTrailers = trailers != ""
|
res.HasTrailers = trailers != ""
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsRequestGzip reports whether we should add an Accept-Encoding: gzip header
|
// IsRequestGzip reports whether we should add an Accept-Encoding: gzip header
|
||||||
// for a request.
|
// for a request.
|
||||||
func IsRequestGzip(req *http.Request, disableCompression bool) bool {
|
func IsRequestGzip(method string, header map[string][]string, disableCompression bool) bool {
|
||||||
// TODO(bradfitz): this is a copy of the logic in net/http. Unify somewhere?
|
// TODO(bradfitz): this is a copy of the logic in net/http. Unify somewhere?
|
||||||
if !disableCompression &&
|
if !disableCompression &&
|
||||||
req.Header.Get("Accept-Encoding") == "" &&
|
len(header["Accept-Encoding"]) == 0 &&
|
||||||
req.Header.Get("Range") == "" &&
|
len(header["Range"]) == 0 &&
|
||||||
req.Method != "HEAD" {
|
method != "HEAD" {
|
||||||
// Request gzip only, not deflate. Deflate is ambiguous and
|
// Request gzip only, not deflate. Deflate is ambiguous and
|
||||||
// not as universally supported anyway.
|
// not as universally supported anyway.
|
||||||
// See: https://zlib.net/zlib_faq.html#faq39
|
// See: https://zlib.net/zlib_faq.html#faq39
|
||||||
@ -280,22 +295,22 @@ func IsRequestGzip(req *http.Request, disableCompression bool) bool {
|
|||||||
//
|
//
|
||||||
// Certain headers are special-cased as okay but not transmitted later.
|
// Certain headers are special-cased as okay but not transmitted later.
|
||||||
// For example, we allow "Transfer-Encoding: chunked", but drop the header when encoding.
|
// For example, we allow "Transfer-Encoding: chunked", but drop the header when encoding.
|
||||||
func checkConnHeaders(req *http.Request) error {
|
func checkConnHeaders(h map[string][]string) error {
|
||||||
if v := req.Header.Get("Upgrade"); v != "" {
|
if vv := h["Upgrade"]; len(vv) > 0 && (vv[0] != "" && vv[0] != "chunked") {
|
||||||
return fmt.Errorf("invalid Upgrade request header: %q", req.Header["Upgrade"])
|
return fmt.Errorf("invalid Upgrade request header: %q", vv)
|
||||||
}
|
}
|
||||||
if vv := req.Header["Transfer-Encoding"]; len(vv) > 0 && (len(vv) > 1 || vv[0] != "" && vv[0] != "chunked") {
|
if vv := h["Transfer-Encoding"]; len(vv) > 0 && (len(vv) > 1 || vv[0] != "" && vv[0] != "chunked") {
|
||||||
return fmt.Errorf("invalid Transfer-Encoding request header: %q", vv)
|
return fmt.Errorf("invalid Transfer-Encoding request header: %q", vv)
|
||||||
}
|
}
|
||||||
if vv := req.Header["Connection"]; len(vv) > 0 && (len(vv) > 1 || vv[0] != "" && !asciiEqualFold(vv[0], "close") && !asciiEqualFold(vv[0], "keep-alive")) {
|
if vv := h["Connection"]; len(vv) > 0 && (len(vv) > 1 || vv[0] != "" && !asciiEqualFold(vv[0], "close") && !asciiEqualFold(vv[0], "keep-alive")) {
|
||||||
return fmt.Errorf("invalid Connection request header: %q", vv)
|
return fmt.Errorf("invalid Connection request header: %q", vv)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func commaSeparatedTrailers(req *http.Request) (string, error) {
|
func commaSeparatedTrailers(trailer map[string][]string) (string, error) {
|
||||||
keys := make([]string, 0, len(req.Trailer))
|
keys := make([]string, 0, len(trailer))
|
||||||
for k := range req.Trailer {
|
for k := range trailer {
|
||||||
k = CanonicalHeader(k)
|
k = CanonicalHeader(k)
|
||||||
switch k {
|
switch k {
|
||||||
case "Transfer-Encoding", "Trailer", "Content-Length":
|
case "Transfer-Encoding", "Trailer", "Content-Length":
|
||||||
@ -310,19 +325,6 @@ func commaSeparatedTrailers(req *http.Request) (string, error) {
|
|||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActualContentLength returns a sanitized version of
|
|
||||||
// req.ContentLength, where 0 actually means zero (not unknown) and -1
|
|
||||||
// means unknown.
|
|
||||||
func ActualContentLength(req *http.Request) int64 {
|
|
||||||
if req.Body == nil || req.Body == http.NoBody {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
if req.ContentLength != 0 {
|
|
||||||
return req.ContentLength
|
|
||||||
}
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
|
|
||||||
// validPseudoPath reports whether v is a valid :path pseudo-header
|
// validPseudoPath reports whether v is a valid :path pseudo-header
|
||||||
// value. It must be either:
|
// value. It must be either:
|
||||||
//
|
//
|
||||||
@ -340,7 +342,7 @@ func validPseudoPath(v string) bool {
|
|||||||
return (len(v) > 0 && v[0] == '/') || v == "*"
|
return (len(v) > 0 && v[0] == '/') || v == "*"
|
||||||
}
|
}
|
||||||
|
|
||||||
func validateHeaders(hdrs http.Header) string {
|
func validateHeaders(hdrs map[string][]string) string {
|
||||||
for k, vv := range hdrs {
|
for k, vv := range hdrs {
|
||||||
if !httpguts.ValidHeaderFieldName(k) && k != ":protocol" {
|
if !httpguts.ValidHeaderFieldName(k) && k != ":protocol" {
|
||||||
return fmt.Sprintf("name %q", k)
|
return fmt.Sprintf("name %q", k)
|
||||||
@ -377,3 +379,89 @@ func shouldSendReqContentLength(method string, contentLength int64) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ServerRequestParam is parameters to NewServerRequest.
|
||||||
|
type ServerRequestParam struct {
|
||||||
|
Method string
|
||||||
|
Scheme, Authority, Path string
|
||||||
|
Protocol string
|
||||||
|
Header map[string][]string
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServerRequestResult is the result of NewServerRequest.
|
||||||
|
type ServerRequestResult struct {
|
||||||
|
// Various http.Request fields.
|
||||||
|
URL *url.URL
|
||||||
|
RequestURI string
|
||||||
|
Trailer map[string][]string
|
||||||
|
|
||||||
|
NeedsContinue bool // client provided an "Expect: 100-continue" header
|
||||||
|
|
||||||
|
// If the request should be rejected, this is a short string suitable for passing
|
||||||
|
// to the http2 package's CountError function.
|
||||||
|
// It might be a bit odd to return errors this way rather than returing an error,
|
||||||
|
// but this ensures we don't forget to include a CountError reason.
|
||||||
|
InvalidReason string
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewServerRequest(rp ServerRequestParam) ServerRequestResult {
|
||||||
|
needsContinue := httpguts.HeaderValuesContainsToken(rp.Header["Expect"], "100-continue")
|
||||||
|
if needsContinue {
|
||||||
|
delete(rp.Header, "Expect")
|
||||||
|
}
|
||||||
|
// Merge Cookie headers into one "; "-delimited value.
|
||||||
|
if cookies := rp.Header["Cookie"]; len(cookies) > 1 {
|
||||||
|
rp.Header["Cookie"] = []string{strings.Join(cookies, "; ")}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup Trailers
|
||||||
|
var trailer map[string][]string
|
||||||
|
for _, v := range rp.Header["Trailer"] {
|
||||||
|
for _, key := range strings.Split(v, ",") {
|
||||||
|
key = textproto.CanonicalMIMEHeaderKey(textproto.TrimString(key))
|
||||||
|
switch key {
|
||||||
|
case "Transfer-Encoding", "Trailer", "Content-Length":
|
||||||
|
// Bogus. (copy of http1 rules)
|
||||||
|
// Ignore.
|
||||||
|
default:
|
||||||
|
if trailer == nil {
|
||||||
|
trailer = make(map[string][]string)
|
||||||
|
}
|
||||||
|
trailer[key] = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete(rp.Header, "Trailer")
|
||||||
|
|
||||||
|
// "':authority' MUST NOT include the deprecated userinfo subcomponent
|
||||||
|
// for "http" or "https" schemed URIs."
|
||||||
|
// https://www.rfc-editor.org/rfc/rfc9113.html#section-8.3.1-2.3.8
|
||||||
|
if strings.IndexByte(rp.Authority, '@') != -1 && (rp.Scheme == "http" || rp.Scheme == "https") {
|
||||||
|
return ServerRequestResult{
|
||||||
|
InvalidReason: "userinfo_in_authority",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var url_ *url.URL
|
||||||
|
var requestURI string
|
||||||
|
if rp.Method == "CONNECT" && rp.Protocol == "" {
|
||||||
|
url_ = &url.URL{Host: rp.Authority}
|
||||||
|
requestURI = rp.Authority // mimic HTTP/1 server behavior
|
||||||
|
} else {
|
||||||
|
var err error
|
||||||
|
url_, err = url.ParseRequestURI(rp.Path)
|
||||||
|
if err != nil {
|
||||||
|
return ServerRequestResult{
|
||||||
|
InvalidReason: "bad_path",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
requestURI = rp.Path
|
||||||
|
}
|
||||||
|
|
||||||
|
return ServerRequestResult{
|
||||||
|
URL: url_,
|
||||||
|
NeedsContinue: needsContinue,
|
||||||
|
RequestURI: requestURI,
|
||||||
|
Trailer: trailer,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
8
vendor/golang.org/x/net/proxy/per_host.go
generated
vendored
8
vendor/golang.org/x/net/proxy/per_host.go
generated
vendored
@ -7,6 +7,7 @@ package proxy
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net"
|
"net"
|
||||||
|
"net/netip"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -57,7 +58,8 @@ func (p *PerHost) DialContext(ctx context.Context, network, addr string) (c net.
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *PerHost) dialerForRequest(host string) Dialer {
|
func (p *PerHost) dialerForRequest(host string) Dialer {
|
||||||
if ip := net.ParseIP(host); ip != nil {
|
if nip, err := netip.ParseAddr(host); err == nil {
|
||||||
|
ip := net.IP(nip.AsSlice())
|
||||||
for _, net := range p.bypassNetworks {
|
for _, net := range p.bypassNetworks {
|
||||||
if net.Contains(ip) {
|
if net.Contains(ip) {
|
||||||
return p.bypass
|
return p.bypass
|
||||||
@ -108,8 +110,8 @@ func (p *PerHost) AddFromString(s string) {
|
|||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if ip := net.ParseIP(host); ip != nil {
|
if nip, err := netip.ParseAddr(host); err == nil {
|
||||||
p.AddIP(ip)
|
p.AddIP(net.IP(nip.AsSlice()))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(host, "*.") {
|
if strings.HasPrefix(host, "*.") {
|
||||||
|
4
vendor/modules.txt
vendored
4
vendor/modules.txt
vendored
@ -1221,8 +1221,8 @@ golang.org/x/exp/maps
|
|||||||
## explicit; go 1.22.0
|
## explicit; go 1.22.0
|
||||||
golang.org/x/mod/semver
|
golang.org/x/mod/semver
|
||||||
golang.org/x/mod/sumdb/note
|
golang.org/x/mod/sumdb/note
|
||||||
# golang.org/x/net v0.35.0
|
# golang.org/x/net v0.36.0
|
||||||
## explicit; go 1.18
|
## explicit; go 1.23.0
|
||||||
golang.org/x/net/bpf
|
golang.org/x/net/bpf
|
||||||
golang.org/x/net/html
|
golang.org/x/net/html
|
||||||
golang.org/x/net/html/atom
|
golang.org/x/net/html/atom
|
||||||
|
Reference in New Issue
Block a user