diff --git a/api/api.go b/api/api.go index 7d7e1061d..f6fe5a1bd 100644 --- a/api/api.go +++ b/api/api.go @@ -2,6 +2,7 @@ package api import ( "bytes" + "context" "crypto/tls" "crypto/x509" "encoding/json" @@ -354,7 +355,7 @@ func NewClient(config *Config) (*Client, error) { config.Scheme = "https" case "unix": trans := cleanhttp.DefaultTransport() - trans.Dial = func(_, _ string) (net.Conn, error) { + trans.DialContext = func(_ context.Context, _, _ string) (net.Conn, error) { return net.Dial("unix", parts[1]) } config.HttpClient = &http.Client{ diff --git a/api/api_test.go b/api/api_test.go index f2f2b40e5..51a206895 100644 --- a/api/api_test.go +++ b/api/api_test.go @@ -42,7 +42,6 @@ func makeClientWithConfig( if cb1 != nil { cb1(conf) } - // Create server server := testutil.NewTestServerConfig(t, cb2) conf.Address = server.HTTPAddr diff --git a/testutil/server.go b/testutil/server.go index 7daa21ed6..f30116cb0 100644 --- a/testutil/server.go +++ b/testutil/server.go @@ -13,6 +13,7 @@ package testutil import ( "bytes" + "context" "encoding/base64" "encoding/json" "fmt" @@ -223,7 +224,7 @@ func NewTestServerConfig(t TestingT, cb ServerConfigCallback) *TestServer { if strings.HasPrefix(consulConfig.Addresses.HTTP, "unix://") { httpAddr = consulConfig.Addresses.HTTP trans := cleanhttp.DefaultTransport() - trans.Dial = func(_, _ string) (net.Conn, error) { + trans.DialContext = func(_ context.Context, _, _ string) (net.Conn, error) { return net.Dial("unix", httpAddr[7:]) } client = &http.Client{ diff --git a/vendor/github.com/hashicorp/go-cleanhttp/cleanhttp.go b/vendor/github.com/hashicorp/go-cleanhttp/cleanhttp.go index f4596d80c..7d8a57c28 100644 --- a/vendor/github.com/hashicorp/go-cleanhttp/cleanhttp.go +++ b/vendor/github.com/hashicorp/go-cleanhttp/cleanhttp.go @@ -3,11 +3,12 @@ package cleanhttp import ( "net" "net/http" + "runtime" "time" ) -// DefaultTransport returns a new http.Transport with the same default values -// as http.DefaultTransport, but with idle connections and keepalives disabled. +// DefaultTransport returns a new http.Transport with similar default values to +// http.DefaultTransport, but with idle connections and keepalives disabled. func DefaultTransport() *http.Transport { transport := DefaultPooledTransport() transport.DisableKeepAlives = true @@ -22,13 +23,15 @@ func DefaultTransport() *http.Transport { func DefaultPooledTransport() *http.Transport { transport := &http.Transport{ Proxy: http.ProxyFromEnvironment, - Dial: (&net.Dialer{ + DialContext: (&net.Dialer{ Timeout: 30 * time.Second, KeepAlive: 30 * time.Second, - }).Dial, - TLSHandshakeTimeout: 10 * time.Second, - DisableKeepAlives: false, - MaxIdleConnsPerHost: 1, + }).DialContext, + MaxIdleConns: 100, + IdleConnTimeout: 90 * time.Second, + TLSHandshakeTimeout: 10 * time.Second, + ExpectContinueTimeout: 1 * time.Second, + MaxIdleConnsPerHost: runtime.GOMAXPROCS(0) + 1, } return transport } @@ -42,10 +45,10 @@ func DefaultClient() *http.Client { } } -// DefaultPooledClient returns a new http.Client with the same default values -// as http.Client, but with a shared Transport. Do not use this function -// for transient clients as it can leak file descriptors over time. Only use -// this for clients that will be re-used for the same host(s). +// DefaultPooledClient returns a new http.Client with similar default values to +// http.Client, but with a shared Transport. Do not use this function for +// transient clients as it can leak file descriptors over time. Only use this +// for clients that will be re-used for the same host(s). func DefaultPooledClient() *http.Client { return &http.Client{ Transport: DefaultPooledTransport(), diff --git a/vendor/vendor.json b/vendor/vendor.json index 88481b9ab..1e949da04 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -438,10 +438,10 @@ "revisionTime": "2015-10-22T18:15:14Z" }, { - "checksumSHA1": "Uzyon2091lmwacNsl1hCytjhHtg=", + "checksumSHA1": "b8F628srIitj5p7Y130xc9k0QWs=", "path": "github.com/hashicorp/go-cleanhttp", - "revision": "ad28ea4487f05916463e2423a55166280e8254b5", - "revisionTime": "2016-04-07T17:41:26Z" + "revision": "3573b8b52aa7b37b9358d966a898feb387f62437", + "revisionTime": "2017-02-11T01:34:15Z" }, { "checksumSHA1": "jPxyofQxI1PRPq6LPc6VlcRn5fI=",