Commit e5d33e73 authored by Tw's avatar Tw

header: implement http.Hijacker for responseWriterWrapper

fix issue #1173
Signed-off-by: default avatarTw <tw19881113@gmail.com>
parent 9ced4b17
......@@ -4,6 +4,9 @@
package header
import (
"bufio"
"errors"
"net"
"net/http"
"strings"
......@@ -113,3 +116,12 @@ func (rww *responseWriterWrapper) setHeader(key, value string) {
h.Set(key, value)
})
}
// Hijack implements http.Hijacker. It simply wraps the underlying
// ResponseWriter's Hijack method if there is one, or returns an error.
func (rww *responseWriterWrapper) Hijack() (net.Conn, *bufio.ReadWriter, error) {
if hj, ok := rww.w.(http.Hijacker); ok {
return hj.Hijack()
}
return nil, nil, errors.New("not a Hijacker")
}
......@@ -189,7 +189,7 @@ func (rp *ReverseProxy) ServeHTTP(rw http.ResponseWriter, outreq *http.Request,
res.Body.Close()
hj, ok := rw.(http.Hijacker)
if !ok {
return nil
panic("not a hijacker")
}
conn, _, err := hj.Hijack()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment