1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-26 03:21:29 +00:00

support Hijacker #428

This commit is contained in:
astaxie 2013-12-31 20:47:48 +08:00
parent 383a04f4c2
commit 1e57587fe9

View File

@ -1,7 +1,10 @@
package beego package beego
import ( import (
"bufio"
"errors"
"fmt" "fmt"
"net"
"net/http" "net/http"
"net/url" "net/url"
"os" "os"
@ -864,3 +867,13 @@ func (w *responseWriter) WriteHeader(code int) {
w.started = true w.started = true
w.writer.WriteHeader(code) w.writer.WriteHeader(code)
} }
// hijacker for http
func (w *responseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
hj, ok := w.writer.(http.Hijacker)
if !ok {
println("supported?")
return nil, nil, errors.New("webserver doesn't support hijacking")
}
return hj.Hijack()
}