0
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-30 22:34:15 -05:00

reverseproxy: Add mention of which half a copyBuffer err comes from (#5472)

Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
This commit is contained in:
Francis Lavoie 2023-03-31 15:46:29 -04:00 committed by GitHub
parent 2b3046de36
commit 66e571e687
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -20,6 +20,7 @@ package reverseproxy
import ( import (
"context" "context"
"fmt"
"io" "io"
weakrand "math/rand" weakrand "math/rand"
"mime" "mime"
@ -215,7 +216,7 @@ func (h Handler) copyBuffer(dst io.Writer, src io.Reader, buf []byte) (int64, er
written += int64(nw) written += int64(nw)
} }
if werr != nil { if werr != nil {
return written, werr return written, fmt.Errorf("writing: %w", werr)
} }
if nr != nw { if nr != nw {
return written, io.ErrShortWrite return written, io.ErrShortWrite
@ -223,9 +224,9 @@ func (h Handler) copyBuffer(dst io.Writer, src io.Reader, buf []byte) (int64, er
} }
if rerr != nil { if rerr != nil {
if rerr == io.EOF { if rerr == io.EOF {
rerr = nil return written, nil
} }
return written, rerr return written, fmt.Errorf("reading: %w", rerr)
} }
} }
} }