From eb7a6d925bac94679138adf9ec9157a0da44d37b Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Mon, 7 Sep 2020 09:26:03 +0200 Subject: [PATCH] fix: header middleware response writer. --- pkg/middlewares/headers/responsewriter.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pkg/middlewares/headers/responsewriter.go b/pkg/middlewares/headers/responsewriter.go index 274a58181..899e8259c 100644 --- a/pkg/middlewares/headers/responsewriter.go +++ b/pkg/middlewares/headers/responsewriter.go @@ -1,6 +1,9 @@ package headers import ( + "bufio" + "fmt" + "net" "net/http" "github.com/containous/traefik/v2/pkg/log" @@ -73,3 +76,19 @@ func (w *responseModifier) Write(b []byte) (int, error) { return w.w.Write(b) } + +// Hijack hijacks the connection. +func (w *responseModifier) Hijack() (net.Conn, *bufio.ReadWriter, error) { + if h, ok := w.w.(http.Hijacker); ok { + return h.Hijack() + } + + return nil, nil, fmt.Errorf("not a hijacker: %T", w.w) +} + +// Flush sends any buffered data to the client. +func (w *responseModifier) Flush() { + if flusher, ok := w.w.(http.Flusher); ok { + flusher.Flush() + } +}