From dfdf4a44a984076ae8f1b04c7910baedfcfe14dc Mon Sep 17 00:00:00 2001 From: Adam Duke Date: Sun, 29 Dec 2024 21:08:34 -0500 Subject: [PATCH] propagate underlying buffer write errors --- buffer/buffer.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/buffer/buffer.go b/buffer/buffer.go index 4c528228..694ecc1c 100644 --- a/buffer/buffer.go +++ b/buffer/buffer.go @@ -189,6 +189,12 @@ func (b *Buffer) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } + if bw.writeError != nil { + b.log.Error("vulcand/oxy/buffer: failed to copy response, err: %v", bw.writeError) + b.errHandler.ServeHTTP(w, req, bw.writeError) + return + } + var reader multibuf.MultiReader if bw.expectBody(outReq) { rdr, err := writer.Reader() @@ -258,6 +264,7 @@ type bufferWriter struct { buffer multibuf.WriterOnce responseWriter http.ResponseWriter hijacked bool + writeError error log utils.Logger } @@ -298,6 +305,7 @@ func (b *bufferWriter) Write(buf []byte) (int, error) { // if the writer returns an error, the reverse proxy panics b.log.Error("write: %v", err) length = len(buf) + b.writeError = err } return length, nil }