Ensure redirector supports Hijacking if possible

This commit is contained in:
Darren Shepherd 2020-02-28 09:30:25 -07:00
parent 9da27b7130
commit 68ed467231

View File

@ -18,6 +18,9 @@ func RedirectRewrite(next http.Handler) http.Handler {
ResponseWriter: rw, ResponseWriter: rw,
prefix: prefix, prefix: prefix,
} }
if h, ok := rw.(http.Hijacker); ok {
r.Hijacker = h
}
next.ServeHTTP(r, req) next.ServeHTTP(r, req)
r.Close() r.Close()
}) })
@ -25,6 +28,7 @@ func RedirectRewrite(next http.Handler) http.Handler {
type redirector struct { type redirector struct {
http.ResponseWriter http.ResponseWriter
http.Hijacker
prefix string prefix string
from, to string from, to string
tempBuffer *bytes.Buffer tempBuffer *bytes.Buffer