Skip to content

Commit fc01e95

Browse files
committed
requestlog: implement Flush in CountingResponseWriter
1 parent d2d18a7 commit fc01e95

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

requestlog/countingresponsewriter.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ type CountingResponseWriter struct {
1818
RequestBody *bytes.Buffer
1919
}
2020

21+
var (
22+
_ http.ResponseWriter = (*CountingResponseWriter)(nil)
23+
_ http.Flusher = (*CountingResponseWriter)(nil)
24+
_ http.Hijacker = (*CountingResponseWriter)(nil)
25+
)
26+
2127
func (crw *CountingResponseWriter) Header() http.Header {
2228
return crw.ResponseWriter.Header()
2329
}
@@ -45,6 +51,14 @@ func (crw *CountingResponseWriter) WriteHeader(statusCode int) {
4551
}
4652
}
4753

54+
func (crw *CountingResponseWriter) Flush() {
55+
flusher, ok := crw.ResponseWriter.(http.Flusher)
56+
if !ok {
57+
return
58+
}
59+
flusher.Flush()
60+
}
61+
4862
func (crw *CountingResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
4963
hijacker, ok := crw.ResponseWriter.(http.Hijacker)
5064
if !ok {

0 commit comments

Comments
 (0)