Pārlūkot izejas kodu

Merge pull request #9108 from vieux/handle_redirects

handle GET redirects over HTTP
Michael Crosby 10 gadi atpakaļ
vecāks
revīzija
df603eb4e4
1 mainītis faili ar 8 papildinājumiem un 4 dzēšanām
  1. 8 4
      api/client/cli.go

+ 8 - 4
api/client/cli.go

@@ -138,14 +138,18 @@ func NewDockerCli(in io.ReadCloser, out, err io.Writer, key libtrust.PrivateKey,
 	// The transport is created here for reuse during the client session
 	tr := &http.Transport{
 		TLSClientConfig: tlsConfig,
-		Dial: func(dial_network, dial_addr string) (net.Conn, error) {
-			// Why 32? See issue 8035
-			return net.DialTimeout(proto, addr, 32*time.Second)
-		},
 	}
+
+	// Why 32? See issue 8035
+	timeout := 32 * time.Second
 	if proto == "unix" {
 		// no need in compressing for local communications
 		tr.DisableCompression = true
+		tr.Dial = func(_, _ string) (net.Conn, error) {
+			return net.DialTimeout(proto, addr, timeout)
+		}
+	} else {
+		tr.Dial = (&net.Dialer{Timeout: timeout}).Dial
 	}
 
 	return &DockerCli{