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 7, 2023
1 parent 4a0f1a3 commit 9c1deaf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion middleware.go
Expand Up @@ -521,7 +521,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 9c1deaf

Please sign in to comment.