fix: header middleware response writer.

This commit is contained in:
Ludovic Fernandez 2020-09-07 09:26:03 +02:00 committed by GitHub
parent 2d1a973ee5
commit eb7a6d925b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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()
}
}