Use http.DefaultClient

The Go docs recommend this.
This commit is contained in:
Matthew Holt 2016-01-27 20:43:51 -07:00
parent 0a560b8761
commit cf4ca2a89d
2 changed files with 5 additions and 10 deletions

View file

@ -61,8 +61,7 @@ func (d *DNSProviderDigitalOcean) Present(domain, token, keyAuth string) error {
req.Header.Set("Content-Type", "application/json") req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", d.apiAuthToken)) req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", d.apiAuthToken))
var client http.Client resp, err := http.DefaultClient.Do(req)
resp, err := client.Do(req)
if err != nil { if err != nil {
return err return err
} }
@ -107,8 +106,7 @@ func (d *DNSProviderDigitalOcean) CleanUp(domain, token, keyAuth string) error {
req.Header.Set("Content-Type", "application/json") req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", d.apiAuthToken)) req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", d.apiAuthToken))
var client http.Client resp, err := http.DefaultClient.Do(req)
resp, err := client.Do(req)
if err != nil { if err != nil {
return err return err
} }

View file

@ -32,8 +32,7 @@ func httpHead(url string) (resp *http.Response, err error) {
req.Header.Set("User-Agent", userAgent()) req.Header.Set("User-Agent", userAgent())
client := http.Client{} resp, err = http.DefaultClient.Do(req)
resp, err = client.Do(req)
if resp.Body != nil { if resp.Body != nil {
resp.Body.Close() resp.Body.Close()
} }
@ -50,8 +49,7 @@ func httpPost(url string, bodyType string, body io.Reader) (resp *http.Response,
req.Header.Set("Content-Type", bodyType) req.Header.Set("Content-Type", bodyType)
req.Header.Set("User-Agent", userAgent()) req.Header.Set("User-Agent", userAgent())
client := http.Client{} return http.DefaultClient.Do(req)
return client.Do(req)
} }
// httpGet performs a GET request with a proper User-Agent string. // httpGet performs a GET request with a proper User-Agent string.
@ -63,8 +61,7 @@ func httpGet(url string) (resp *http.Response, err error) {
} }
req.Header.Set("User-Agent", userAgent()) req.Header.Set("User-Agent", userAgent())
client := http.Client{} return http.DefaultClient.Do(req)
return client.Do(req)
} }
// getJSON performs an HTTP GET request and parses the response body // getJSON performs an HTTP GET request and parses the response body