1. Fix w. (http. Flusher). Flush() error (#3388)

This commit is contained in:
扶桑花间
2023-07-05 23:27:15 +08:00
committed by GitHub
parent a86942d532
commit 916cea858f
2 changed files with 42 additions and 0 deletions

View File

@@ -128,7 +128,13 @@ type timeoutWriter struct {
var _ http.Pusher = (*timeoutWriter)(nil)
func (tw *timeoutWriter) Flush() {
dst := tw.w.Header()
for k, vv := range tw.h {
dst[k] = vv
}
if flusher, ok := tw.w.(http.Flusher); ok {
tw.w.Write(tw.wbuf.Bytes())
tw.wbuf.Reset()
flusher.Flush()
}
}