Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 13, 04:15 UTC
reverseproxy: Add mention of which half a copyBuffer err comes from (#5472)
Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
Francis Lavoie committed
Mar 31, 2023 at 15:46 UTC
66e571e687eeddca0aafd5df0e3ab5f7cecbdcfa
1 file changed
+4
-3
modules/caddyhttp/reverseproxy/streaming.go
+4
-3
@@ -20,6 +20,7 @@ package reverseproxy
20
21
import (
22
"context"
23
+ "fmt"
24
"io"
25
weakrand "math/rand"
26
"mime"
@@ -215,7 +216,7 @@ func (h Handler) copyBuffer(dst io.Writer, src io.Reader, buf []byte) (int64, er
216
written += int64(nw)
217
}
218
if werr != nil {
218
- return written, werr
219
+ return written, fmt.Errorf("writing: %w", werr)
220
}
221
if nr != nw {
222
return written, io.ErrShortWrite
@@ -223,9 +224,9 @@ func (h Handler) copyBuffer(dst io.Writer, src io.Reader, buf []byte) (int64, er
224
}
225
if rerr != nil {
226
if rerr == io.EOF {
226
- rerr = nil
227
+ return written, nil
228
}
228
- return written, rerr
229
+ return written, fmt.Errorf("reading: %w", rerr)
230
}
231
}
232
}