diff --git a/middleware/proxy/reverseproxy.go b/middleware/proxy/reverseproxy.go index 384ea6cde..05538dfc2 100644 --- a/middleware/proxy/reverseproxy.go +++ b/middleware/proxy/reverseproxy.go @@ -111,7 +111,7 @@ func NewSingleHostReverseProxy(target *url.URL, without string) *ReverseProxy { req.URL.Path = strings.TrimPrefix(req.URL.Path, without) } } - rp := &ReverseProxy{Director: director} + rp := &ReverseProxy{Director: director, FlushInterval: 250 * time.Millisecond} // flushing good for streaming & server-sent events if target.Scheme == "unix" { rp.Transport = &http.Transport{ Dial: socketDial(target.String()), diff --git a/middleware/recorder.go b/middleware/recorder.go index 585c5c335..44d277365 100644 --- a/middleware/recorder.go +++ b/middleware/recorder.go @@ -77,3 +77,11 @@ func (r *ResponseRecorder) Hijack() (net.Conn, *bufio.ReadWriter, error) { } return nil, nil, errors.New("not a Hijacker") } + +// Flush implements http.Flusher. It simply wraps the underlying +// ResponseWriter's Flush method if there is one, or does nothing. +func (r *ResponseRecorder) Flush() { + if f, ok := r.ResponseWriter.(http.Flusher); ok { + f.Flush() + } +}