Skip to content

Commit

Permalink
Use buffer from the pool
Browse files Browse the repository at this point in the history
  • Loading branch information
jeevatkm committed Mar 8, 2023
1 parent 53ad0ae commit 2e0dbde
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ func saveResponseIntoFile(c *Client, res *Response) error {
func getBodyCopy(r *Request) (*bytes.Buffer, error) {
// If r.bodyBuf present, return the copy
if r.bodyBuf != nil {
bodyCopy := &bytes.Buffer{}
bodyCopy := acquireBuffer()
if _, err := io.Copy(bodyCopy, bytes.NewReader(r.bodyBuf.Bytes())); err != nil {
// cannot use io.Copy(bodyCopy, r.bodyBuf) because io.Copy reset r.bodyBuf
return nil, err
Expand Down

0 comments on commit 2e0dbde

Please sign in to comment.