mirror of
https://github.com/docker/cli.git
synced 2026-11-06 13:10:41 -04:00
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:
+15
-1
@@ -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...)
|
||||
|
||||
Reference in New Issue
Block a user