Add auto Flush to core WriteBuffer

This commit is contained in:
Alex X
2023-09-16 11:09:46 +03:00
parent 93e475f3a4
commit f910bd4fce
+3
View File
@@ -3,6 +3,7 @@ package core
import ( import (
"bytes" "bytes"
"io" "io"
"net/http"
"sync" "sync"
) )
@@ -32,6 +33,8 @@ func (w *WriteBuffer) Write(p []byte) (n int, err error) {
} else if n, err = w.Writer.Write(p); err != nil { } else if n, err = w.Writer.Write(p); err != nil {
w.err = err w.err = err
w.done() w.done()
} else if f, ok := w.Writer.(http.Flusher); ok {
f.Flush()
} }
w.mu.Unlock() w.mu.Unlock()
return return