diff options
author | Francis Lavoie <lavofr@gmail.com> | 2023-03-31 15:46:29 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-31 15:46:29 -0400 |
commit | 66e571e687eeddca0aafd5df0e3ab5f7cecbdcfa (patch) | |
tree | eeebc63de36c0449659d6a0ae0b9ee040567daed | |
parent | 2b3046de36bad70bd7e48478c99a8a030fb35b98 (diff) |
reverseproxy: Add mention of which half a copyBuffer err comes from (#5472)
Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
-rw-r--r-- | modules/caddyhttp/reverseproxy/streaming.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/modules/caddyhttp/reverseproxy/streaming.go b/modules/caddyhttp/reverseproxy/streaming.go index 1db107a..1f5387e 100644 --- a/modules/caddyhttp/reverseproxy/streaming.go +++ b/modules/caddyhttp/reverseproxy/streaming.go @@ -20,6 +20,7 @@ package reverseproxy import ( "context" + "fmt" "io" weakrand "math/rand" "mime" @@ -215,7 +216,7 @@ func (h Handler) copyBuffer(dst io.Writer, src io.Reader, buf []byte) (int64, er written += int64(nw) } if werr != nil { - return written, werr + return written, fmt.Errorf("writing: %w", werr) } if nr != nw { 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 == io.EOF { - rerr = nil + return written, nil } - return written, rerr + return written, fmt.Errorf("reading: %w", rerr) } } } |