Add context to all http.NewRequest #3257

When we drop support for go1.12 we can use http.NewRequestWithContext
This commit is contained in:
Nick Craig-Wood
2019-09-04 20:21:10 +01:00
parent 58a531a203
commit 66c23723e3
13 changed files with 70 additions and 46 deletions

View File

@@ -212,10 +212,11 @@ func (api *Client) Call(ctx context.Context, opts *Opts) (resp *http.Response, e
if opts.ContentLength != nil && *opts.ContentLength == 0 {
body = nil
}
req, err := http.NewRequestWithContext(ctx, opts.Method, url, body)
req, err := http.NewRequest(opts.Method, url, body)
if err != nil {
return
}
req = req.WithContext(ctx) // go1.13 can use NewRequestWithContext
headers := make(map[string]string)
// Set default headers
for k, v := range api.headers {