mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
81fa9feb0c
Signed by all authors: Signed-off-by: Michael Crosby <crosbymichael@gmail.com> Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com> Signed-off-by: David Calavera <david.calavera@gmail.com> Signed-off-by: Jeff Lindsay <progrium@gmail.com> Signed-off-by: Alexander Morozov <lk4d4@docker.com> Signed-off-by: Luke Marsden <luke@clusterhq.com> Signed-off-by: David Calavera <david.calavera@gmail.com>
22 lines
524 B
Go
22 lines
524 B
Go
package utils
|
|
|
|
import (
|
|
"net"
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
func ConfigureTCPTransport(tr *http.Transport, proto, addr string) {
|
|
// Why 32? See https://github.com/docker/docker/pull/8035.
|
|
timeout := 32 * time.Second
|
|
if proto == "unix" {
|
|
// No need for compression in local communications.
|
|
tr.DisableCompression = true
|
|
tr.Dial = func(_, _ string) (net.Conn, error) {
|
|
return net.DialTimeout(proto, addr, timeout)
|
|
}
|
|
} else {
|
|
tr.Proxy = http.ProxyFromEnvironment
|
|
tr.Dial = (&net.Dialer{Timeout: timeout}).Dial
|
|
}
|
|
}
|