1
0
mirror of https://github.com/rclone/rclone.git synced 2026-01-07 19:13:19 +00:00

Use http.NewRequestWithContext where possible after go1.13 minimum version

This commit is contained in:
Nick Craig-Wood
2021-02-03 17:41:27 +00:00
parent 15e1a6bee7
commit bcac8fdc83
11 changed files with 17 additions and 34 deletions

View File

@@ -184,11 +184,10 @@ func doCall(ctx context.Context, path string, in rc.Params) (out rc.Params, err
return nil, errors.Wrap(err, "failed to encode JSON")
}
req, err := http.NewRequest("POST", url, bytes.NewBuffer(data))
req, err := http.NewRequestWithContext(ctx, "POST", url, bytes.NewBuffer(data))
if err != nil {
return nil, errors.Wrap(err, "failed to make request")
}
req = req.WithContext(ctx) // go1.13 can use NewRequestWithContext
req.Header.Set("Content-Type", "application/json")
if authUser != "" || authPass != "" {