Skip to content

Commit

Permalink
Don't use http.DefaultClient
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jefferai committed Oct 15, 2015
1 parent 8ecf4d1 commit f49fc09
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "" {
Expand Down
8 changes: 5 additions & 3 deletions command/agent/ui_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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) {
Expand All @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion testutil/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit f49fc09

Please sign in to comment.