Skip to content

Commit

Permalink
fix imroc#10
Browse files Browse the repository at this point in the history
  • Loading branch information
imroc committed Jun 4, 2017
1 parent 8168d3b commit 02374e7
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions resp.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,16 @@ func (r *Resp) ToFile(name string) error {
if err != nil {
return err
}
_, err = io.Copy(file, r.resp.Body)
if err != nil {
return err
if r.respBody != nil {
_, err = file.Write(r.respBody)
if err != nil {
return err
}
} else {
_, err = io.Copy(file, r.resp.Body)
if err != nil {
return err
}
}
return nil
}
Expand Down

0 comments on commit 02374e7

Please sign in to comment.