feat: add support for hijack

master v0.1.0
Evan Chen 2021-11-19 15:08:51 +08:00
parent c5073d7a74
commit 6793e8ef1d
1 changed files with 10 additions and 0 deletions

View File

@ -1,7 +1,9 @@
package guard
import (
"bufio"
"encoding/base64"
"errors"
"fmt"
"net"
"net/http"
@ -33,6 +35,14 @@ type responseWriter struct {
err string
}
func (w *responseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
h, ok := w.ResponseWriter.(http.Hijacker)
if !ok {
return nil, nil, errors.New("hijack not supported")
}
return h.Hijack()
}
func (w *responseWriter) WriteHeader(statusCode int) {
if w.StatueCode != 0 {
return