mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-06 02:48:48 +03:00
Merge pull request #134 from tw4452852/hijack
middleware: let middleware.responseRecorder be a http.Hijacker
This commit is contained in:
commit
d7051e986f
1 changed files with 12 additions and 0 deletions
|
@ -1,6 +1,9 @@
|
|||
package middleware
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"net"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
@ -48,3 +51,12 @@ func (r *responseRecorder) Write(buf []byte) (int, error) {
|
|||
}
|
||||
return n, err
|
||||
}
|
||||
|
||||
// Hijacker is a wrapper of http.Hijacker underearth if any,
|
||||
// otherwise it just returns an error.
|
||||
func (r *responseRecorder) Hijack() (net.Conn, *bufio.ReadWriter, error) {
|
||||
if hj, ok := r.ResponseWriter.(http.Hijacker); ok {
|
||||
return hj.Hijack()
|
||||
}
|
||||
return nil, nil, errors.New("I'm not a Hijacker")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue