Skip to content

Commit

Permalink
Remove http.DefaultClient altogether
Browse files Browse the repository at this point in the history
Use a global http.Client from cleanhttp for all http requests, unless
specifically overridden.
  • Loading branch information
jbardin committed Sep 12, 2017
1 parent 18ee990 commit 50bc684
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions get.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ var Getters map[string]Getter
// syntax is schema::url, example: git::https://foo.com
var forcedRegexp = regexp.MustCompile(`^([A-Za-z0-9]+)::(.+)$`)

// httpClient is the default client to be used by HttpGetters.
var httpClient = cleanhttp.DefaultClient()

func init() {
httpGetter := &HttpGetter{
Netrc: true,
Client: cleanhttp.DefaultClient(),
Netrc: true,
}

Getters = map[string]Getter{
Expand Down
6 changes: 3 additions & 3 deletions get_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type HttpGetter struct {
Netrc bool

// Client is the http.Client to use for Get requests.
// This defaults to http.DefaultClient if left unset.
// This defaults to a cleanhttp.DefaultClient if left unset.
Client *http.Client
}

Expand All @@ -62,7 +62,7 @@ func (g *HttpGetter) Get(dst string, u *url.URL) error {
}

if g.Client == nil {
g.Client = http.DefaultClient
g.Client = httpClient
}

// Add terraform-get to the parameter.
Expand Down Expand Up @@ -115,7 +115,7 @@ func (g *HttpGetter) GetFile(dst string, u *url.URL) error {
}

if g.Client == nil {
g.Client = http.DefaultClient
g.Client = httpClient
}

resp, err := g.Client.Get(u.String())
Expand Down

0 comments on commit 50bc684

Please sign in to comment.