Skip to content

Commit 0c3bea2

Browse files
committed
using NewRequestWithContext to crate Request
1 parent e5f8277 commit 0c3bea2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

request.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func (r *Requester) SetClient(client *http.Client) *Requester {
138138
return r
139139
}
140140

141-
//Add auth on redirect if required.
141+
// Add auth on redirect if required.
142142
func (r *Requester) redirectPolicyFunc(req *http.Request, via []*http.Request) error {
143143
if r.BasicAuth != nil {
144144
req.SetBasicAuth(r.BasicAuth.Username, r.BasicAuth.Password)
@@ -206,14 +206,14 @@ func (r *Requester) Do(ctx context.Context, ar *APIRequest, responseStruct inter
206206
if err = writer.Close(); err != nil {
207207
return nil, err
208208
}
209-
req, err = http.NewRequest(ar.Method, URL.String(), body)
209+
req, err = http.NewRequestWithContext(ctx, ar.Method, URL.String(), body)
210210
if err != nil {
211211
return nil, err
212212
}
213213
req.Header.Set("Content-Type", writer.FormDataContentType())
214214
} else {
215215

216-
req, err = http.NewRequest(ar.Method, URL.String(), ar.Payload)
216+
req, err = http.NewRequestWithContext(ctx, ar.Method, URL.String(), ar.Payload)
217217
if err != nil {
218218
return nil, err
219219
}

0 commit comments

Comments
 (0)