From 0a7ca64f53970dbbf94567ace6c873be9fabb69b Mon Sep 17 00:00:00 2001 From: Matt Holt Date: Mon, 11 Apr 2016 00:24:26 -0600 Subject: [PATCH] gzipResponseWriter should also be a Flusher To be consistent with 3faad41b437c48cea37863123fab425169bc0c6e and c64cf218b0a82d144e779454817eb0371a5002a8 --- middleware/gzip/gzip.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/middleware/gzip/gzip.go b/middleware/gzip/gzip.go index f24a94aa..4ef65855 100644 --- a/middleware/gzip/gzip.go +++ b/middleware/gzip/gzip.go @@ -142,6 +142,16 @@ func (w *gzipResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) { return nil, nil, fmt.Errorf("not a Hijacker") } +// Flush implements http.Flusher. It simply wraps the underlying +// ResponseWriter's Flush method if there is one, or panics. +func (w *gzipResponseWriter) Flush() { + if f, ok := w.ResponseWriter.(http.Flusher); ok { + f.Flush() + } else { + panic("not a Flusher") // should be recovered at the beginning of middleware stack + } +} + // CloseNotify implements http.CloseNotifier. // It just inherits the underlying ResponseWriter's CloseNotify method. func (w *gzipResponseWriter) CloseNotify() <-chan bool {