Skip to content

Commit

Permalink
check if body exists before copy
Browse files Browse the repository at this point in the history
  • Loading branch information
aldor007 committed Nov 12, 2017
1 parent f839918 commit 2dc2322
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions response/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,16 @@ func (r * Response) Copy() (*Response, error) {
c.Headers[k] = v
}

buf, err := r.CopyBody()
if err != nil {
return nil, err
}
if r.Stream != nil {
buf, err := r.CopyBody()
if err != nil {
return nil, err
}

c.Stream = ioutil.NopCloser(bytes.NewReader(buf))
c.ContentLength = int64(len(buf))
c.Stream = ioutil.NopCloser(bytes.NewReader(buf))
c.ContentLength = int64(len(buf))

}

return &c, nil

Expand Down

0 comments on commit 2dc2322

Please sign in to comment.