vendor: golang.org/x/net v0.31.0
full diff: https://github.com/golang/net/compare/v0.30.0...v0.31.0 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
6751bcc972
commit
9399483f7a
@ -96,7 +96,7 @@ require (
|
|||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0 // indirect
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0 // indirect
|
||||||
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
|
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
|
||||||
golang.org/x/crypto v0.29.0 // indirect
|
golang.org/x/crypto v0.29.0 // indirect
|
||||||
golang.org/x/net v0.30.0 // indirect
|
golang.org/x/net v0.31.0 // indirect
|
||||||
golang.org/x/time v0.6.0 // indirect
|
golang.org/x/time v0.6.0 // indirect
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9 // indirect
|
google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9 // indirect
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9 // indirect
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9 // indirect
|
||||||
|
@ -327,8 +327,8 @@ golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLL
|
|||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
|
golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo=
|
||||||
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
|
golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM=
|
||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
8
vendor/golang.org/x/net/http2/client_conn_pool.go
generated
vendored
8
vendor/golang.org/x/net/http2/client_conn_pool.go
generated
vendored
@ -8,8 +8,8 @@ package http2
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/tls"
|
|
||||||
"errors"
|
"errors"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
@ -158,7 +158,7 @@ func (c *dialCall) dial(ctx context.Context, addr string) {
|
|||||||
// This code decides which ones live or die.
|
// This code decides which ones live or die.
|
||||||
// The return value used is whether c was used.
|
// The return value used is whether c was used.
|
||||||
// c is never closed.
|
// c is never closed.
|
||||||
func (p *clientConnPool) addConnIfNeeded(key string, t *Transport, c *tls.Conn) (used bool, err error) {
|
func (p *clientConnPool) addConnIfNeeded(key string, t *Transport, c net.Conn) (used bool, err error) {
|
||||||
p.mu.Lock()
|
p.mu.Lock()
|
||||||
for _, cc := range p.conns[key] {
|
for _, cc := range p.conns[key] {
|
||||||
if cc.CanTakeNewRequest() {
|
if cc.CanTakeNewRequest() {
|
||||||
@ -194,8 +194,8 @@ type addConnCall struct {
|
|||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *addConnCall) run(t *Transport, key string, tc *tls.Conn) {
|
func (c *addConnCall) run(t *Transport, key string, nc net.Conn) {
|
||||||
cc, err := t.NewClientConn(tc)
|
cc, err := t.NewClientConn(nc)
|
||||||
|
|
||||||
p := c.p
|
p := c.p
|
||||||
p.mu.Lock()
|
p.mu.Lock()
|
||||||
|
28
vendor/golang.org/x/net/http2/server.go
generated
vendored
28
vendor/golang.org/x/net/http2/server.go
generated
vendored
@ -306,7 +306,7 @@ func ConfigureServer(s *http.Server, conf *Server) error {
|
|||||||
if s.TLSNextProto == nil {
|
if s.TLSNextProto == nil {
|
||||||
s.TLSNextProto = map[string]func(*http.Server, *tls.Conn, http.Handler){}
|
s.TLSNextProto = map[string]func(*http.Server, *tls.Conn, http.Handler){}
|
||||||
}
|
}
|
||||||
protoHandler := func(hs *http.Server, c *tls.Conn, h http.Handler) {
|
protoHandler := func(hs *http.Server, c net.Conn, h http.Handler, sawClientPreface bool) {
|
||||||
if testHookOnConn != nil {
|
if testHookOnConn != nil {
|
||||||
testHookOnConn()
|
testHookOnConn()
|
||||||
}
|
}
|
||||||
@ -326,9 +326,28 @@ func ConfigureServer(s *http.Server, conf *Server) error {
|
|||||||
Context: ctx,
|
Context: ctx,
|
||||||
Handler: h,
|
Handler: h,
|
||||||
BaseConfig: hs,
|
BaseConfig: hs,
|
||||||
|
SawClientPreface: sawClientPreface,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
s.TLSNextProto[NextProtoTLS] = protoHandler
|
s.TLSNextProto[NextProtoTLS] = func(hs *http.Server, c *tls.Conn, h http.Handler) {
|
||||||
|
protoHandler(hs, c, h, false)
|
||||||
|
}
|
||||||
|
// The "unencrypted_http2" TLSNextProto key is used to pass off non-TLS HTTP/2 conns.
|
||||||
|
//
|
||||||
|
// A connection passed in this method has already had the HTTP/2 preface read from it.
|
||||||
|
s.TLSNextProto[nextProtoUnencryptedHTTP2] = func(hs *http.Server, c *tls.Conn, h http.Handler) {
|
||||||
|
nc, err := unencryptedNetConnFromTLSConn(c)
|
||||||
|
if err != nil {
|
||||||
|
if lg := hs.ErrorLog; lg != nil {
|
||||||
|
lg.Print(err)
|
||||||
|
} else {
|
||||||
|
log.Print(err)
|
||||||
|
}
|
||||||
|
go c.Close()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
protoHandler(hs, nc, h, true)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2880,6 +2899,11 @@ func (w *responseWriter) SetWriteDeadline(deadline time.Time) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *responseWriter) EnableFullDuplex() error {
|
||||||
|
// We always support full duplex responses, so this is a no-op.
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (w *responseWriter) Flush() {
|
func (w *responseWriter) Flush() {
|
||||||
w.FlushError()
|
w.FlushError()
|
||||||
}
|
}
|
||||||
|
226
vendor/golang.org/x/net/http2/transport.go
generated
vendored
226
vendor/golang.org/x/net/http2/transport.go
generated
vendored
@ -202,6 +202,20 @@ func (t *Transport) markNewGoroutine() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *Transport) now() time.Time {
|
||||||
|
if t != nil && t.transportTestHooks != nil {
|
||||||
|
return t.transportTestHooks.group.Now()
|
||||||
|
}
|
||||||
|
return time.Now()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *Transport) timeSince(when time.Time) time.Duration {
|
||||||
|
if t != nil && t.transportTestHooks != nil {
|
||||||
|
return t.now().Sub(when)
|
||||||
|
}
|
||||||
|
return time.Since(when)
|
||||||
|
}
|
||||||
|
|
||||||
// newTimer creates a new time.Timer, or a synthetic timer in tests.
|
// newTimer creates a new time.Timer, or a synthetic timer in tests.
|
||||||
func (t *Transport) newTimer(d time.Duration) timer {
|
func (t *Transport) newTimer(d time.Duration) timer {
|
||||||
if t.transportTestHooks != nil {
|
if t.transportTestHooks != nil {
|
||||||
@ -281,8 +295,8 @@ func configureTransports(t1 *http.Transport) (*Transport, error) {
|
|||||||
if !strSliceContains(t1.TLSClientConfig.NextProtos, "http/1.1") {
|
if !strSliceContains(t1.TLSClientConfig.NextProtos, "http/1.1") {
|
||||||
t1.TLSClientConfig.NextProtos = append(t1.TLSClientConfig.NextProtos, "http/1.1")
|
t1.TLSClientConfig.NextProtos = append(t1.TLSClientConfig.NextProtos, "http/1.1")
|
||||||
}
|
}
|
||||||
upgradeFn := func(authority string, c *tls.Conn) http.RoundTripper {
|
upgradeFn := func(scheme, authority string, c net.Conn) http.RoundTripper {
|
||||||
addr := authorityAddr("https", authority)
|
addr := authorityAddr(scheme, authority)
|
||||||
if used, err := connPool.addConnIfNeeded(addr, t2, c); err != nil {
|
if used, err := connPool.addConnIfNeeded(addr, t2, c); err != nil {
|
||||||
go c.Close()
|
go c.Close()
|
||||||
return erringRoundTripper{err}
|
return erringRoundTripper{err}
|
||||||
@ -293,18 +307,37 @@ func configureTransports(t1 *http.Transport) (*Transport, error) {
|
|||||||
// was unknown)
|
// was unknown)
|
||||||
go c.Close()
|
go c.Close()
|
||||||
}
|
}
|
||||||
|
if scheme == "http" {
|
||||||
|
return (*unencryptedTransport)(t2)
|
||||||
|
}
|
||||||
return t2
|
return t2
|
||||||
}
|
}
|
||||||
if m := t1.TLSNextProto; len(m) == 0 {
|
if t1.TLSNextProto == nil {
|
||||||
t1.TLSNextProto = map[string]func(string, *tls.Conn) http.RoundTripper{
|
t1.TLSNextProto = make(map[string]func(string, *tls.Conn) http.RoundTripper)
|
||||||
"h2": upgradeFn,
|
|
||||||
}
|
}
|
||||||
} else {
|
t1.TLSNextProto[NextProtoTLS] = func(authority string, c *tls.Conn) http.RoundTripper {
|
||||||
m["h2"] = upgradeFn
|
return upgradeFn("https", authority, c)
|
||||||
|
}
|
||||||
|
// The "unencrypted_http2" TLSNextProto key is used to pass off non-TLS HTTP/2 conns.
|
||||||
|
t1.TLSNextProto[nextProtoUnencryptedHTTP2] = func(authority string, c *tls.Conn) http.RoundTripper {
|
||||||
|
nc, err := unencryptedNetConnFromTLSConn(c)
|
||||||
|
if err != nil {
|
||||||
|
go c.Close()
|
||||||
|
return erringRoundTripper{err}
|
||||||
|
}
|
||||||
|
return upgradeFn("http", authority, nc)
|
||||||
}
|
}
|
||||||
return t2, nil
|
return t2, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// unencryptedTransport is a Transport with a RoundTrip method that
|
||||||
|
// always permits http:// URLs.
|
||||||
|
type unencryptedTransport Transport
|
||||||
|
|
||||||
|
func (t *unencryptedTransport) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||||
|
return (*Transport)(t).RoundTripOpt(req, RoundTripOpt{allowHTTP: true})
|
||||||
|
}
|
||||||
|
|
||||||
func (t *Transport) connPool() ClientConnPool {
|
func (t *Transport) connPool() ClientConnPool {
|
||||||
t.connPoolOnce.Do(t.initConnPool)
|
t.connPoolOnce.Do(t.initConnPool)
|
||||||
return t.connPoolOrDef
|
return t.connPoolOrDef
|
||||||
@ -324,7 +357,7 @@ type ClientConn struct {
|
|||||||
t *Transport
|
t *Transport
|
||||||
tconn net.Conn // usually *tls.Conn, except specialized impls
|
tconn net.Conn // usually *tls.Conn, except specialized impls
|
||||||
tlsState *tls.ConnectionState // nil only for specialized impls
|
tlsState *tls.ConnectionState // nil only for specialized impls
|
||||||
reused uint32 // whether conn is being reused; atomic
|
atomicReused uint32 // whether conn is being reused; atomic
|
||||||
singleUse bool // whether being used for a single http.Request
|
singleUse bool // whether being used for a single http.Request
|
||||||
getConnCalled bool // used by clientConnPool
|
getConnCalled bool // used by clientConnPool
|
||||||
|
|
||||||
@ -364,6 +397,14 @@ type ClientConn struct {
|
|||||||
readIdleTimeout time.Duration
|
readIdleTimeout time.Duration
|
||||||
pingTimeout time.Duration
|
pingTimeout time.Duration
|
||||||
|
|
||||||
|
// pendingResets is the number of RST_STREAM frames we have sent to the peer,
|
||||||
|
// without confirming that the peer has received them. When we send a RST_STREAM,
|
||||||
|
// we bundle it with a PING frame, unless a PING is already in flight. We count
|
||||||
|
// the reset stream against the connection's concurrency limit until we get
|
||||||
|
// a PING response. This limits the number of requests we'll try to send to a
|
||||||
|
// completely unresponsive connection.
|
||||||
|
pendingResets int
|
||||||
|
|
||||||
// reqHeaderMu is a 1-element semaphore channel controlling access to sending new requests.
|
// reqHeaderMu is a 1-element semaphore channel controlling access to sending new requests.
|
||||||
// Write to reqHeaderMu to lock it, read from it to unlock.
|
// Write to reqHeaderMu to lock it, read from it to unlock.
|
||||||
// Lock reqmu BEFORE mu or wmu.
|
// Lock reqmu BEFORE mu or wmu.
|
||||||
@ -423,9 +464,9 @@ type clientStream struct {
|
|||||||
firstByte bool // got the first response byte
|
firstByte bool // got the first response byte
|
||||||
pastHeaders bool // got first MetaHeadersFrame (actual headers)
|
pastHeaders bool // got first MetaHeadersFrame (actual headers)
|
||||||
pastTrailers bool // got optional second MetaHeadersFrame (trailers)
|
pastTrailers bool // got optional second MetaHeadersFrame (trailers)
|
||||||
num1xx uint8 // number of 1xx responses seen
|
|
||||||
readClosed bool // peer sent an END_STREAM flag
|
readClosed bool // peer sent an END_STREAM flag
|
||||||
readAborted bool // read loop reset the stream
|
readAborted bool // read loop reset the stream
|
||||||
|
totalHeaderSize int64 // total size of 1xx headers seen
|
||||||
|
|
||||||
trailer http.Header // accumulated trailers
|
trailer http.Header // accumulated trailers
|
||||||
resTrailer *http.Header // client's Response.Trailer
|
resTrailer *http.Header // client's Response.Trailer
|
||||||
@ -530,6 +571,8 @@ type RoundTripOpt struct {
|
|||||||
// no cached connection is available, RoundTripOpt
|
// no cached connection is available, RoundTripOpt
|
||||||
// will return ErrNoCachedConn.
|
// will return ErrNoCachedConn.
|
||||||
OnlyCachedConn bool
|
OnlyCachedConn bool
|
||||||
|
|
||||||
|
allowHTTP bool // allow http:// URLs
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) {
|
func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||||
@ -562,7 +605,14 @@ func authorityAddr(scheme string, authority string) (addr string) {
|
|||||||
|
|
||||||
// RoundTripOpt is like RoundTrip, but takes options.
|
// RoundTripOpt is like RoundTrip, but takes options.
|
||||||
func (t *Transport) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Response, error) {
|
func (t *Transport) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Response, error) {
|
||||||
if !(req.URL.Scheme == "https" || (req.URL.Scheme == "http" && t.AllowHTTP)) {
|
switch req.URL.Scheme {
|
||||||
|
case "https":
|
||||||
|
// Always okay.
|
||||||
|
case "http":
|
||||||
|
if !t.AllowHTTP && !opt.allowHTTP {
|
||||||
|
return nil, errors.New("http2: unencrypted HTTP/2 not enabled")
|
||||||
|
}
|
||||||
|
default:
|
||||||
return nil, errors.New("http2: unsupported scheme")
|
return nil, errors.New("http2: unsupported scheme")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -573,7 +623,7 @@ func (t *Transport) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Res
|
|||||||
t.vlogf("http2: Transport failed to get client conn for %s: %v", addr, err)
|
t.vlogf("http2: Transport failed to get client conn for %s: %v", addr, err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
reused := !atomic.CompareAndSwapUint32(&cc.reused, 0, 1)
|
reused := !atomic.CompareAndSwapUint32(&cc.atomicReused, 0, 1)
|
||||||
traceGotConn(req, cc, reused)
|
traceGotConn(req, cc, reused)
|
||||||
res, err := cc.RoundTrip(req)
|
res, err := cc.RoundTrip(req)
|
||||||
if err != nil && retry <= 6 {
|
if err != nil && retry <= 6 {
|
||||||
@ -598,6 +648,22 @@ func (t *Transport) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Res
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if err == errClientConnNotEstablished {
|
||||||
|
// This ClientConn was created recently,
|
||||||
|
// this is the first request to use it,
|
||||||
|
// and the connection is closed and not usable.
|
||||||
|
//
|
||||||
|
// In this state, cc.idleTimer will remove the conn from the pool
|
||||||
|
// when it fires. Stop the timer and remove it here so future requests
|
||||||
|
// won't try to use this connection.
|
||||||
|
//
|
||||||
|
// If the timer has already fired and we're racing it, the redundant
|
||||||
|
// call to MarkDead is harmless.
|
||||||
|
if cc.idleTimer != nil {
|
||||||
|
cc.idleTimer.Stop()
|
||||||
|
}
|
||||||
|
t.connPool().MarkDead(cc)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.vlogf("RoundTrip failure: %v", err)
|
t.vlogf("RoundTrip failure: %v", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -618,6 +684,7 @@ func (t *Transport) CloseIdleConnections() {
|
|||||||
var (
|
var (
|
||||||
errClientConnClosed = errors.New("http2: client conn is closed")
|
errClientConnClosed = errors.New("http2: client conn is closed")
|
||||||
errClientConnUnusable = errors.New("http2: client conn not usable")
|
errClientConnUnusable = errors.New("http2: client conn not usable")
|
||||||
|
errClientConnNotEstablished = errors.New("http2: client conn could not be established")
|
||||||
errClientConnGotGoAway = errors.New("http2: Transport received Server's graceful shutdown GOAWAY")
|
errClientConnGotGoAway = errors.New("http2: Transport received Server's graceful shutdown GOAWAY")
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -757,6 +824,7 @@ func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, erro
|
|||||||
pingTimeout: conf.PingTimeout,
|
pingTimeout: conf.PingTimeout,
|
||||||
pings: make(map[[8]byte]chan struct{}),
|
pings: make(map[[8]byte]chan struct{}),
|
||||||
reqHeaderMu: make(chan struct{}, 1),
|
reqHeaderMu: make(chan struct{}, 1),
|
||||||
|
lastActive: t.now(),
|
||||||
}
|
}
|
||||||
var group synctestGroupInterface
|
var group synctestGroupInterface
|
||||||
if t.transportTestHooks != nil {
|
if t.transportTestHooks != nil {
|
||||||
@ -960,7 +1028,7 @@ func (cc *ClientConn) State() ClientConnState {
|
|||||||
return ClientConnState{
|
return ClientConnState{
|
||||||
Closed: cc.closed,
|
Closed: cc.closed,
|
||||||
Closing: cc.closing || cc.singleUse || cc.doNotReuse || cc.goAway != nil,
|
Closing: cc.closing || cc.singleUse || cc.doNotReuse || cc.goAway != nil,
|
||||||
StreamsActive: len(cc.streams),
|
StreamsActive: len(cc.streams) + cc.pendingResets,
|
||||||
StreamsReserved: cc.streamsReserved,
|
StreamsReserved: cc.streamsReserved,
|
||||||
StreamsPending: cc.pendingRequests,
|
StreamsPending: cc.pendingRequests,
|
||||||
LastIdle: cc.lastIdle,
|
LastIdle: cc.lastIdle,
|
||||||
@ -992,16 +1060,38 @@ func (cc *ClientConn) idleStateLocked() (st clientConnIdleState) {
|
|||||||
// writing it.
|
// writing it.
|
||||||
maxConcurrentOkay = true
|
maxConcurrentOkay = true
|
||||||
} else {
|
} else {
|
||||||
maxConcurrentOkay = int64(len(cc.streams)+cc.streamsReserved+1) <= int64(cc.maxConcurrentStreams)
|
// We can take a new request if the total of
|
||||||
|
// - active streams;
|
||||||
|
// - reservation slots for new streams; and
|
||||||
|
// - streams for which we have sent a RST_STREAM and a PING,
|
||||||
|
// but received no subsequent frame
|
||||||
|
// is less than the concurrency limit.
|
||||||
|
maxConcurrentOkay = cc.currentRequestCountLocked() < int(cc.maxConcurrentStreams)
|
||||||
}
|
}
|
||||||
|
|
||||||
st.canTakeNewRequest = cc.goAway == nil && !cc.closed && !cc.closing && maxConcurrentOkay &&
|
st.canTakeNewRequest = cc.goAway == nil && !cc.closed && !cc.closing && maxConcurrentOkay &&
|
||||||
!cc.doNotReuse &&
|
!cc.doNotReuse &&
|
||||||
int64(cc.nextStreamID)+2*int64(cc.pendingRequests) < math.MaxInt32 &&
|
int64(cc.nextStreamID)+2*int64(cc.pendingRequests) < math.MaxInt32 &&
|
||||||
!cc.tooIdleLocked()
|
!cc.tooIdleLocked()
|
||||||
|
|
||||||
|
// If this connection has never been used for a request and is closed,
|
||||||
|
// then let it take a request (which will fail).
|
||||||
|
//
|
||||||
|
// This avoids a situation where an error early in a connection's lifetime
|
||||||
|
// goes unreported.
|
||||||
|
if cc.nextStreamID == 1 && cc.streamsReserved == 0 && cc.closed {
|
||||||
|
st.canTakeNewRequest = true
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// currentRequestCountLocked reports the number of concurrency slots currently in use,
|
||||||
|
// including active streams, reserved slots, and reset streams waiting for acknowledgement.
|
||||||
|
func (cc *ClientConn) currentRequestCountLocked() int {
|
||||||
|
return len(cc.streams) + cc.streamsReserved + cc.pendingResets
|
||||||
|
}
|
||||||
|
|
||||||
func (cc *ClientConn) canTakeNewRequestLocked() bool {
|
func (cc *ClientConn) canTakeNewRequestLocked() bool {
|
||||||
st := cc.idleStateLocked()
|
st := cc.idleStateLocked()
|
||||||
return st.canTakeNewRequest
|
return st.canTakeNewRequest
|
||||||
@ -1014,7 +1104,7 @@ func (cc *ClientConn) tooIdleLocked() bool {
|
|||||||
// times are compared based on their wall time. We don't want
|
// times are compared based on their wall time. We don't want
|
||||||
// to reuse a connection that's been sitting idle during
|
// to reuse a connection that's been sitting idle during
|
||||||
// VM/laptop suspend if monotonic time was also frozen.
|
// VM/laptop suspend if monotonic time was also frozen.
|
||||||
return cc.idleTimeout != 0 && !cc.lastIdle.IsZero() && time.Since(cc.lastIdle.Round(0)) > cc.idleTimeout
|
return cc.idleTimeout != 0 && !cc.lastIdle.IsZero() && cc.t.timeSince(cc.lastIdle.Round(0)) > cc.idleTimeout
|
||||||
}
|
}
|
||||||
|
|
||||||
// onIdleTimeout is called from a time.AfterFunc goroutine. It will
|
// onIdleTimeout is called from a time.AfterFunc goroutine. It will
|
||||||
@ -1578,6 +1668,7 @@ func (cs *clientStream) cleanupWriteRequest(err error) {
|
|||||||
cs.reqBodyClosed = make(chan struct{})
|
cs.reqBodyClosed = make(chan struct{})
|
||||||
}
|
}
|
||||||
bodyClosed := cs.reqBodyClosed
|
bodyClosed := cs.reqBodyClosed
|
||||||
|
closeOnIdle := cc.singleUse || cc.doNotReuse || cc.t.disableKeepAlives() || cc.goAway != nil
|
||||||
cc.mu.Unlock()
|
cc.mu.Unlock()
|
||||||
if mustCloseBody {
|
if mustCloseBody {
|
||||||
cs.reqBody.Close()
|
cs.reqBody.Close()
|
||||||
@ -1602,16 +1693,40 @@ func (cs *clientStream) cleanupWriteRequest(err error) {
|
|||||||
if cs.sentHeaders {
|
if cs.sentHeaders {
|
||||||
if se, ok := err.(StreamError); ok {
|
if se, ok := err.(StreamError); ok {
|
||||||
if se.Cause != errFromPeer {
|
if se.Cause != errFromPeer {
|
||||||
cc.writeStreamReset(cs.ID, se.Code, err)
|
cc.writeStreamReset(cs.ID, se.Code, false, err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cc.writeStreamReset(cs.ID, ErrCodeCancel, err)
|
// We're cancelling an in-flight request.
|
||||||
|
//
|
||||||
|
// This could be due to the server becoming unresponsive.
|
||||||
|
// To avoid sending too many requests on a dead connection,
|
||||||
|
// we let the request continue to consume a concurrency slot
|
||||||
|
// until we can confirm the server is still responding.
|
||||||
|
// We do this by sending a PING frame along with the RST_STREAM
|
||||||
|
// (unless a ping is already in flight).
|
||||||
|
//
|
||||||
|
// For simplicity, we don't bother tracking the PING payload:
|
||||||
|
// We reset cc.pendingResets any time we receive a PING ACK.
|
||||||
|
//
|
||||||
|
// We skip this if the conn is going to be closed on idle,
|
||||||
|
// because it's short lived and will probably be closed before
|
||||||
|
// we get the ping response.
|
||||||
|
ping := false
|
||||||
|
if !closeOnIdle {
|
||||||
|
cc.mu.Lock()
|
||||||
|
if cc.pendingResets == 0 {
|
||||||
|
ping = true
|
||||||
|
}
|
||||||
|
cc.pendingResets++
|
||||||
|
cc.mu.Unlock()
|
||||||
|
}
|
||||||
|
cc.writeStreamReset(cs.ID, ErrCodeCancel, ping, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cs.bufPipe.CloseWithError(err) // no-op if already closed
|
cs.bufPipe.CloseWithError(err) // no-op if already closed
|
||||||
} else {
|
} else {
|
||||||
if cs.sentHeaders && !cs.sentEndStream {
|
if cs.sentHeaders && !cs.sentEndStream {
|
||||||
cc.writeStreamReset(cs.ID, ErrCodeNo, nil)
|
cc.writeStreamReset(cs.ID, ErrCodeNo, false, nil)
|
||||||
}
|
}
|
||||||
cs.bufPipe.CloseWithError(errRequestCanceled)
|
cs.bufPipe.CloseWithError(errRequestCanceled)
|
||||||
}
|
}
|
||||||
@ -1633,12 +1748,17 @@ func (cs *clientStream) cleanupWriteRequest(err error) {
|
|||||||
// Must hold cc.mu.
|
// Must hold cc.mu.
|
||||||
func (cc *ClientConn) awaitOpenSlotForStreamLocked(cs *clientStream) error {
|
func (cc *ClientConn) awaitOpenSlotForStreamLocked(cs *clientStream) error {
|
||||||
for {
|
for {
|
||||||
cc.lastActive = time.Now()
|
if cc.closed && cc.nextStreamID == 1 && cc.streamsReserved == 0 {
|
||||||
|
// This is the very first request sent to this connection.
|
||||||
|
// Return a fatal error which aborts the retry loop.
|
||||||
|
return errClientConnNotEstablished
|
||||||
|
}
|
||||||
|
cc.lastActive = cc.t.now()
|
||||||
if cc.closed || !cc.canTakeNewRequestLocked() {
|
if cc.closed || !cc.canTakeNewRequestLocked() {
|
||||||
return errClientConnUnusable
|
return errClientConnUnusable
|
||||||
}
|
}
|
||||||
cc.lastIdle = time.Time{}
|
cc.lastIdle = time.Time{}
|
||||||
if int64(len(cc.streams)) < int64(cc.maxConcurrentStreams) {
|
if cc.currentRequestCountLocked() < int(cc.maxConcurrentStreams) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
cc.pendingRequests++
|
cc.pendingRequests++
|
||||||
@ -2180,10 +2300,10 @@ func (cc *ClientConn) forgetStreamID(id uint32) {
|
|||||||
if len(cc.streams) != slen-1 {
|
if len(cc.streams) != slen-1 {
|
||||||
panic("forgetting unknown stream id")
|
panic("forgetting unknown stream id")
|
||||||
}
|
}
|
||||||
cc.lastActive = time.Now()
|
cc.lastActive = cc.t.now()
|
||||||
if len(cc.streams) == 0 && cc.idleTimer != nil {
|
if len(cc.streams) == 0 && cc.idleTimer != nil {
|
||||||
cc.idleTimer.Reset(cc.idleTimeout)
|
cc.idleTimer.Reset(cc.idleTimeout)
|
||||||
cc.lastIdle = time.Now()
|
cc.lastIdle = cc.t.now()
|
||||||
}
|
}
|
||||||
// Wake up writeRequestBody via clientStream.awaitFlowControl and
|
// Wake up writeRequestBody via clientStream.awaitFlowControl and
|
||||||
// wake up RoundTrip if there is a pending request.
|
// wake up RoundTrip if there is a pending request.
|
||||||
@ -2243,7 +2363,6 @@ func isEOFOrNetReadError(err error) bool {
|
|||||||
|
|
||||||
func (rl *clientConnReadLoop) cleanup() {
|
func (rl *clientConnReadLoop) cleanup() {
|
||||||
cc := rl.cc
|
cc := rl.cc
|
||||||
cc.t.connPool().MarkDead(cc)
|
|
||||||
defer cc.closeConn()
|
defer cc.closeConn()
|
||||||
defer close(cc.readerDone)
|
defer close(cc.readerDone)
|
||||||
|
|
||||||
@ -2267,6 +2386,24 @@ func (rl *clientConnReadLoop) cleanup() {
|
|||||||
}
|
}
|
||||||
cc.closed = true
|
cc.closed = true
|
||||||
|
|
||||||
|
// If the connection has never been used, and has been open for only a short time,
|
||||||
|
// leave it in the connection pool for a little while.
|
||||||
|
//
|
||||||
|
// This avoids a situation where new connections are constantly created,
|
||||||
|
// added to the pool, fail, and are removed from the pool, without any error
|
||||||
|
// being surfaced to the user.
|
||||||
|
const unusedWaitTime = 5 * time.Second
|
||||||
|
idleTime := cc.t.now().Sub(cc.lastActive)
|
||||||
|
if atomic.LoadUint32(&cc.atomicReused) == 0 && idleTime < unusedWaitTime {
|
||||||
|
cc.idleTimer = cc.t.afterFunc(unusedWaitTime-idleTime, func() {
|
||||||
|
cc.t.connPool().MarkDead(cc)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
cc.mu.Unlock() // avoid any deadlocks in MarkDead
|
||||||
|
cc.t.connPool().MarkDead(cc)
|
||||||
|
cc.mu.Lock()
|
||||||
|
}
|
||||||
|
|
||||||
for _, cs := range cc.streams {
|
for _, cs := range cc.streams {
|
||||||
select {
|
select {
|
||||||
case <-cs.peerClosed:
|
case <-cs.peerClosed:
|
||||||
@ -2494,15 +2631,34 @@ func (rl *clientConnReadLoop) handleResponse(cs *clientStream, f *MetaHeadersFra
|
|||||||
if f.StreamEnded() {
|
if f.StreamEnded() {
|
||||||
return nil, errors.New("1xx informational response with END_STREAM flag")
|
return nil, errors.New("1xx informational response with END_STREAM flag")
|
||||||
}
|
}
|
||||||
cs.num1xx++
|
|
||||||
const max1xxResponses = 5 // arbitrary bound on number of informational responses, same as net/http
|
|
||||||
if cs.num1xx > max1xxResponses {
|
|
||||||
return nil, errors.New("http2: too many 1xx informational responses")
|
|
||||||
}
|
|
||||||
if fn := cs.get1xxTraceFunc(); fn != nil {
|
if fn := cs.get1xxTraceFunc(); fn != nil {
|
||||||
|
// If the 1xx response is being delivered to the user,
|
||||||
|
// then they're responsible for limiting the number
|
||||||
|
// of responses.
|
||||||
if err := fn(statusCode, textproto.MIMEHeader(header)); err != nil {
|
if err := fn(statusCode, textproto.MIMEHeader(header)); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// If the user didn't examine the 1xx response, then we
|
||||||
|
// limit the size of all 1xx headers.
|
||||||
|
//
|
||||||
|
// This differs a bit from the HTTP/1 implementation, which
|
||||||
|
// limits the size of all 1xx headers plus the final response.
|
||||||
|
// Use the larger limit of MaxHeaderListSize and
|
||||||
|
// net/http.Transport.MaxResponseHeaderBytes.
|
||||||
|
limit := int64(cs.cc.t.maxHeaderListSize())
|
||||||
|
if t1 := cs.cc.t.t1; t1 != nil && t1.MaxResponseHeaderBytes > limit {
|
||||||
|
limit = t1.MaxResponseHeaderBytes
|
||||||
|
}
|
||||||
|
for _, h := range f.Fields {
|
||||||
|
cs.totalHeaderSize += int64(h.Size())
|
||||||
|
}
|
||||||
|
if cs.totalHeaderSize > limit {
|
||||||
|
if VerboseLogs {
|
||||||
|
log.Printf("http2: 1xx informational responses too large")
|
||||||
|
}
|
||||||
|
return nil, errors.New("header list too large")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if statusCode == 100 {
|
if statusCode == 100 {
|
||||||
traceGot100Continue(cs.trace)
|
traceGot100Continue(cs.trace)
|
||||||
@ -3046,6 +3202,11 @@ func (rl *clientConnReadLoop) processPing(f *PingFrame) error {
|
|||||||
close(c)
|
close(c)
|
||||||
delete(cc.pings, f.Data)
|
delete(cc.pings, f.Data)
|
||||||
}
|
}
|
||||||
|
if cc.pendingResets > 0 {
|
||||||
|
// See clientStream.cleanupWriteRequest.
|
||||||
|
cc.pendingResets = 0
|
||||||
|
cc.cond.Broadcast()
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
cc := rl.cc
|
cc := rl.cc
|
||||||
@ -3068,13 +3229,20 @@ func (rl *clientConnReadLoop) processPushPromise(f *PushPromiseFrame) error {
|
|||||||
return ConnectionError(ErrCodeProtocol)
|
return ConnectionError(ErrCodeProtocol)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cc *ClientConn) writeStreamReset(streamID uint32, code ErrCode, err error) {
|
// writeStreamReset sends a RST_STREAM frame.
|
||||||
|
// When ping is true, it also sends a PING frame with a random payload.
|
||||||
|
func (cc *ClientConn) writeStreamReset(streamID uint32, code ErrCode, ping bool, err error) {
|
||||||
// TODO: map err to more interesting error codes, once the
|
// TODO: map err to more interesting error codes, once the
|
||||||
// HTTP community comes up with some. But currently for
|
// HTTP community comes up with some. But currently for
|
||||||
// RST_STREAM there's no equivalent to GOAWAY frame's debug
|
// RST_STREAM there's no equivalent to GOAWAY frame's debug
|
||||||
// data, and the error codes are all pretty vague ("cancel").
|
// data, and the error codes are all pretty vague ("cancel").
|
||||||
cc.wmu.Lock()
|
cc.wmu.Lock()
|
||||||
cc.fr.WriteRSTStream(streamID, code)
|
cc.fr.WriteRSTStream(streamID, code)
|
||||||
|
if ping {
|
||||||
|
var payload [8]byte
|
||||||
|
rand.Read(payload[:])
|
||||||
|
cc.fr.WritePing(false, payload)
|
||||||
|
}
|
||||||
cc.bw.Flush()
|
cc.bw.Flush()
|
||||||
cc.wmu.Unlock()
|
cc.wmu.Unlock()
|
||||||
}
|
}
|
||||||
@ -3228,7 +3396,7 @@ func traceGotConn(req *http.Request, cc *ClientConn, reused bool) {
|
|||||||
cc.mu.Lock()
|
cc.mu.Lock()
|
||||||
ci.WasIdle = len(cc.streams) == 0 && reused
|
ci.WasIdle = len(cc.streams) == 0 && reused
|
||||||
if ci.WasIdle && !cc.lastActive.IsZero() {
|
if ci.WasIdle && !cc.lastActive.IsZero() {
|
||||||
ci.IdleTime = time.Since(cc.lastActive)
|
ci.IdleTime = cc.t.timeSince(cc.lastActive)
|
||||||
}
|
}
|
||||||
cc.mu.Unlock()
|
cc.mu.Unlock()
|
||||||
|
|
||||||
|
32
vendor/golang.org/x/net/http2/unencrypted.go
generated
vendored
Normal file
32
vendor/golang.org/x/net/http2/unencrypted.go
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// Copyright 2024 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package http2
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/tls"
|
||||||
|
"errors"
|
||||||
|
"net"
|
||||||
|
)
|
||||||
|
|
||||||
|
const nextProtoUnencryptedHTTP2 = "unencrypted_http2"
|
||||||
|
|
||||||
|
// unencryptedNetConnFromTLSConn retrieves a net.Conn wrapped in a *tls.Conn.
|
||||||
|
//
|
||||||
|
// TLSNextProto functions accept a *tls.Conn.
|
||||||
|
//
|
||||||
|
// When passing an unencrypted HTTP/2 connection to a TLSNextProto function,
|
||||||
|
// we pass a *tls.Conn with an underlying net.Conn containing the unencrypted connection.
|
||||||
|
// To be extra careful about mistakes (accidentally dropping TLS encryption in a place
|
||||||
|
// where we want it), the tls.Conn contains a net.Conn with an UnencryptedNetConn method
|
||||||
|
// that returns the actual connection we want to use.
|
||||||
|
func unencryptedNetConnFromTLSConn(tc *tls.Conn) (net.Conn, error) {
|
||||||
|
conner, ok := tc.NetConn().(interface {
|
||||||
|
UnencryptedNetConn() net.Conn
|
||||||
|
})
|
||||||
|
if !ok {
|
||||||
|
return nil, errors.New("http2: TLS conn unexpectedly found in unencrypted handoff")
|
||||||
|
}
|
||||||
|
return conner.UnencryptedNetConn(), nil
|
||||||
|
}
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -387,7 +387,7 @@ go.opentelemetry.io/proto/otlp/trace/v1
|
|||||||
## explicit; go 1.20
|
## explicit; go 1.20
|
||||||
golang.org/x/crypto/ed25519
|
golang.org/x/crypto/ed25519
|
||||||
golang.org/x/crypto/pbkdf2
|
golang.org/x/crypto/pbkdf2
|
||||||
# golang.org/x/net v0.30.0
|
# golang.org/x/net v0.31.0
|
||||||
## explicit; go 1.18
|
## explicit; go 1.18
|
||||||
golang.org/x/net/http/httpguts
|
golang.org/x/net/http/httpguts
|
||||||
golang.org/x/net/http2
|
golang.org/x/net/http2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user