diff --git a/src/net/http/transfer.go b/src/net/http/transfer.go index b24998174f6..dffff56b31e 100644 --- a/src/net/http/transfer.go +++ b/src/net/http/transfer.go @@ -410,7 +410,11 @@ func (t *transferWriter) writeBody(w io.Writer) (err error) { // // This function is only intended for use in writeBody. func (t *transferWriter) doBodyCopy(dst io.Writer, src io.Reader) (n int64, err error) { - n, err = io.Copy(dst, src) + bufp := copyBufPool.Get().(*[]byte) + buf := *bufp + defer copyBufPool.Put(bufp) + + n, err = io.CopyBuffer(dst, src, buf) if err != nil && err != io.EOF { t.bodyReadError = err }