Skip to content

Commit

Permalink
propogate underlying buffer write errors
Browse files Browse the repository at this point in the history
  • Loading branch information
adamvduke committed Dec 30, 2024
1 parent 20c03af commit 9bbed94
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions buffer/buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -258,6 +264,7 @@ type bufferWriter struct {
buffer multibuf.WriterOnce
responseWriter http.ResponseWriter
hijacked bool
writeError error
log utils.Logger
}

Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 9bbed94

Please sign in to comment.