vendor: github.com/moby/moby/client v0.6.2

full diff: https://github.com/moby/moby/compare/client/v0.6.1...client/v0.6.2

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski
2026-10-08 22:08:10 +02:00
parent e7df01fe6e
commit 730c880b35
4 changed files with 19 additions and 5 deletions
+15 -1
View File
@@ -42,7 +42,7 @@ func (cli *Client) DialHijack(ctx context.Context, url, proto string, meta map[s
return conn, err
}
func (cli *Client) setupHijackConn(req *http.Request, proto string) (_ net.Conn, _ string, retErr error) {
func (cli *Client) setupHijackConn(req *http.Request, proto string) (retConn net.Conn, mediaType string, retErr error) {
ctx := req.Context()
req.Header.Set("Connection", "Upgrade")
req.Header.Set("Upgrade", proto)
@@ -70,6 +70,20 @@ func (cli *Client) setupHijackConn(req *http.Request, proto string) (_ net.Conn,
hc := &hijackedConn{conn, bufio.NewReader(conn)}
// Cancel the handshake without tying the returned connection to ctx.
cancelled := make(chan struct{})
stop := context.AfterFunc(ctx, func() {
_ = hc.Conn.Close()
close(cancelled)
})
defer func() {
if !stop() {
// Cancellation won the race; don't return a connection being closed.
<-cancelled
retConn, mediaType, retErr = nil, "", ctx.Err()
}
}()
cfg := &cli.clientConfig
var rt http.RoundTripper = otelhttp.NewTransport(hc, cli.traceOpts...)