Skip to content

Commit

Permalink
adding nil check
Browse files Browse the repository at this point in the history
  • Loading branch information
Mzack9999 committed Nov 30, 2022
1 parent e655acc commit ef3e4ed
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,13 @@ func (r *Request) WithContext(ctx context.Context) *Request {

// FromRequest wraps an http.Request in a retryablehttp.Request
func FromRequest(r *http.Request) (*Request, error) {
body, err := fileutil.NewReusableReader(r.Body)
if err != nil {
return nil, err
if r.Body != nil {
body, err := fileutil.NewReusableReader(r.Body)
if err != nil {
return nil, err
}
r.Body = body
}
r.Body = body
bodyReader, contentLength, err := getBodyReaderAndContentLength(r.Body)
if err != nil {
return nil, err
Expand Down

0 comments on commit ef3e4ed

Please sign in to comment.