diff --git a/api/api.go b/api/api.go index 46037c59179..52ce1bc9067 100644 --- a/api/api.go +++ b/api/api.go @@ -10,6 +10,8 @@ import ( "os" "strconv" "time" + + "github.com/hashicorp/cleanhttp" ) // QueryOptions are used to parameterize a query @@ -86,7 +88,7 @@ type Config struct { func DefaultConfig() *Config { config := &Config{ Address: "http://127.0.0.1:4646", - HttpClient: &http.Client{}, + HttpClient: cleanhttp.DefaultClient(), } if addr := os.Getenv("NOMAD_ADDR"); addr != "" { config.Address = addr diff --git a/client/fingerprint/env_aws.go b/client/fingerprint/env_aws.go index a65933a1e61..78cae8a1d0f 100644 --- a/client/fingerprint/env_aws.go +++ b/client/fingerprint/env_aws.go @@ -10,6 +10,7 @@ import ( "strings" "time" + "github.com/hashicorp/cleanhttp" "github.com/hashicorp/nomad/client/config" "github.com/hashicorp/nomad/nomad/structs" ) @@ -93,7 +94,8 @@ func (f *EnvAWSFingerprint) Fingerprint(cfg *config.Config, node *structs.Node) // assume 2 seconds is enough time for inside AWS network client := &http.Client{ - Timeout: 2 * time.Second, + Timeout: 2 * time.Second, + Transport: cleanhttp.DefaultTransport(), } keys := []string{ @@ -164,7 +166,8 @@ func isAWS() bool { // assume 2 seconds is enough time for inside AWS network client := &http.Client{ - Timeout: 2 * time.Second, + Timeout: 2 * time.Second, + Transport: cleanhttp.DefaultTransport(), } // Query the metadata url for the ami-id, to veryify we're on AWS @@ -207,7 +210,8 @@ func (f *EnvAWSFingerprint) linkSpeed() int { // assume 2 seconds is enough time for inside AWS network client := &http.Client{ - Timeout: 2 * time.Second, + Timeout: 2 * time.Second, + Transport: cleanhttp.DefaultTransport(), } res, err := client.Get(metadataURL + "instance-type") diff --git a/client/fingerprint/env_gce.go b/client/fingerprint/env_gce.go index b20978db008..48f5df328a0 100644 --- a/client/fingerprint/env_gce.go +++ b/client/fingerprint/env_gce.go @@ -12,6 +12,7 @@ import ( "strings" "time" + "github.com/hashicorp/cleanhttp" "github.com/hashicorp/nomad/client/config" "github.com/hashicorp/nomad/nomad/structs" ) @@ -61,7 +62,8 @@ func NewEnvGCEFingerprint(logger *log.Logger) Fingerprint { // assume 2 seconds is enough time for inside GCE network client := &http.Client{ - Timeout: 2 * time.Second, + Timeout: 2 * time.Second, + Transport: cleanhttp.DefaultTransport(), } return &EnvGCEFingerprint{ diff --git a/testutil/server.go b/testutil/server.go index c1a804f87b7..04389a1133e 100644 --- a/testutil/server.go +++ b/testutil/server.go @@ -22,6 +22,8 @@ import ( "os/exec" "sync/atomic" "testing" + + "github.com/hashicorp/cleanhttp" ) // offset is used to atomically increment the port numbers. @@ -156,7 +158,7 @@ func NewTestServer(t *testing.T, cb ServerConfigCallback) *TestServer { t.Fatalf("err: %s", err) } - client := &http.Client{} + client := cleanhttp.DefaultClient() server := &TestServer{ Config: nomadConfig,