Merge pull request #515 from teeverc/fix/response-rewriter-streaming-flush

fix(amp): flush response buffer after each streaming chunk write
This commit is contained in:
Luis Pater
2025-12-14 13:26:05 +08:00
committed by GitHub

View File

@@ -39,7 +39,13 @@ func (rw *ResponseRewriter) Write(data []byte) (int, error) {
} }
if rw.isStreaming { if rw.isStreaming {
return rw.ResponseWriter.Write(rw.rewriteStreamChunk(data)) n, err := rw.ResponseWriter.Write(rw.rewriteStreamChunk(data))
if err == nil {
if flusher, ok := rw.ResponseWriter.(http.Flusher); ok {
flusher.Flush()
}
}
return n, err
} }
return rw.body.Write(data) return rw.body.Write(data)
} }