From 9cddc187b533f79fd6cbdc6304e1d92fc6d776c5 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Thu, 15 Oct 2015 17:45:10 -0400 Subject: [PATCH] Don't use http.DefaultClient Two of the changes are in tests; the one of consequence is in the API. As explained in #1308 this can cause conflicts with downstream programs. Fixes #1308. --- api/api.go | 2 +- command/agent/ui_endpoint_test.go | 8 +++++--- testutil/server.go | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/api/api.go b/api/api.go index b0b712834..0d248f655 100644 --- a/api/api.go +++ b/api/api.go @@ -119,7 +119,7 @@ func DefaultConfig() *Config { config := &Config{ Address: "127.0.0.1:8500", Scheme: "http", - HttpClient: http.DefaultClient, + HttpClient: &http.Client{}, } if addr := os.Getenv("CONSUL_HTTP_ADDR"); addr != "" { diff --git a/command/agent/ui_endpoint_test.go b/command/agent/ui_endpoint_test.go index 7872ce7be..1d964d622 100644 --- a/command/agent/ui_endpoint_test.go +++ b/command/agent/ui_endpoint_test.go @@ -3,8 +3,6 @@ package agent import ( "bytes" "fmt" - "github.com/hashicorp/consul/consul/structs" - "github.com/hashicorp/consul/testutil" "io" "io/ioutil" "net/http" @@ -13,6 +11,9 @@ import ( "path/filepath" "reflect" "testing" + + "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/testutil" ) func TestUiIndex(t *testing.T) { @@ -36,7 +37,8 @@ func TestUiIndex(t *testing.T) { req.URL.Host = srv.listener.Addr().String() // Make the request - resp, err := http.DefaultClient.Do(req) + client := &http.Client{} + resp, err := client.Do(req) if err != nil { t.Fatalf("err: %v", err) } diff --git a/testutil/server.go b/testutil/server.go index d4ab7afe3..ac77b6c7a 100644 --- a/testutil/server.go +++ b/testutil/server.go @@ -200,7 +200,7 @@ func NewTestServerConfig(t *testing.T, cb ServerConfigCallback) *TestServer { } } else { httpAddr = fmt.Sprintf("127.0.0.1:%d", consulConfig.Ports.HTTP) - client = http.DefaultClient + client = &http.Client{} } server := &TestServer{