fix: reject logs after response flush failure

This commit is contained in:
MiMoCode
2026-07-10 18:39:00 +08:00
parent 3292eb38fc
commit d2cb0107a6
2 changed files with 38 additions and 5 deletions
+10 -5
View File
@@ -66,16 +66,21 @@ func (c *captureWriter) Write(p []byte) (int, error) {
if isStreamResponse(c.Header()) {
c.sse.Write(p[:n])
}
if f, ok := c.ResponseWriter.(http.Flusher); ok {
f.Flush()
}
c.flush()
}
return n, err
}
func (c *captureWriter) Flush() {
if f, ok := c.ResponseWriter.(http.Flusher); ok {
f.Flush()
c.flush()
}
func (c *captureWriter) flush() {
if _, ok := c.ResponseWriter.(http.Flusher); !ok {
return
}
if err := http.NewResponseController(c.ResponseWriter).Flush(); err != nil {
c.writeFailed = true
}
}