mirror of
https://gitee.com/johng/gf
synced 2026-07-07 06:15:15 +08:00
improve stream response for http (#2564)
This commit is contained in:
@ -95,11 +95,11 @@ func Test_Issue2509(t *testing.T) {
|
||||
q.Push(1)
|
||||
q.Push(2)
|
||||
q.Push(3)
|
||||
t.Assert(q.Len(), 3)
|
||||
t.AssertLE(q.Len(), 3)
|
||||
t.Assert(<-q.C, 1)
|
||||
t.Assert(q.Len(), 2)
|
||||
t.AssertLE(q.Len(), 2)
|
||||
t.Assert(<-q.C, 2)
|
||||
t.Assert(q.Len(), 1)
|
||||
t.AssertLE(q.Len(), 1)
|
||||
t.Assert(<-q.C, 3)
|
||||
t.Assert(q.Len(), 0)
|
||||
})
|
||||
|
||||
@ -65,5 +65,8 @@ func (w *ResponseWriter) Flush() {
|
||||
if w.buffer.Len() > 0 {
|
||||
_, _ = w.writer.Write(w.buffer.Bytes())
|
||||
w.buffer.Reset()
|
||||
if flusher, ok := w.RawWriter().(http.Flusher); ok {
|
||||
flusher.Flush()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user