fix: reject logs after response flush failure
This commit is contained in:
+10
-5
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user