From 1e57587fe902edcb9c1554387365043d8c08cea5 Mon Sep 17 00:00:00 2001 From: astaxie Date: Tue, 31 Dec 2013 20:47:48 +0800 Subject: [PATCH] support Hijacker #428 --- router.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/router.go b/router.go index 5047497f..401fddbb 100644 --- a/router.go +++ b/router.go @@ -1,7 +1,10 @@ package beego import ( + "bufio" + "errors" "fmt" + "net" "net/http" "net/url" "os" @@ -864,3 +867,13 @@ func (w *responseWriter) WriteHeader(code int) { w.started = true 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() +}