Skip to content

Commit

Permalink
using NewRequestWithContext to crate Request
Browse files Browse the repository at this point in the history
  • Loading branch information
Frapschen committed Dec 9, 2022
1 parent e5f8277 commit 0c3bea2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (r *Requester) SetClient(client *http.Client) *Requester {
return r
}

//Add auth on redirect if required.
// Add auth on redirect if required.
func (r *Requester) redirectPolicyFunc(req *http.Request, via []*http.Request) error {
if r.BasicAuth != nil {
req.SetBasicAuth(r.BasicAuth.Username, r.BasicAuth.Password)
Expand Down Expand Up @@ -206,14 +206,14 @@ func (r *Requester) Do(ctx context.Context, ar *APIRequest, responseStruct inter
if err = writer.Close(); err != nil {
return nil, err
}
req, err = http.NewRequest(ar.Method, URL.String(), body)
req, err = http.NewRequestWithContext(ctx, ar.Method, URL.String(), body)
if err != nil {
return nil, err
}
req.Header.Set("Content-Type", writer.FormDataContentType())
} else {

req, err = http.NewRequest(ar.Method, URL.String(), ar.Payload)
req, err = http.NewRequestWithContext(ctx, ar.Method, URL.String(), ar.Payload)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 0c3bea2

Please sign in to comment.