http: add Hijacker type; remove Hijack from ResponseWriter

The Hijack functionality wasn't removed, but now you have
to test if your ResponseWriter is also a Hijacker:

func ServeHTTP(rw http.ResponseWriter, req *http.Request) {
    if hj, ok := rw.(http.Hijacker); ok {
        hj.Hijack(..)
    }
}

R=rsc
CC=golang-dev
https://golang.org/cl/4245064
This commit is contained in:
Brad Fitzpatrick 2011-03-06 18:59:50 -08:00
parent 8b432848f4
commit 545a1eef6a
4 changed files with 6 additions and 12 deletions

View file

@ -527,7 +527,7 @@ func (server *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) {
io.WriteString(w, "405 must CONNECT\n")
return
}
conn, _, err := w.Hijack()
conn, _, err := w.(http.Hijacker).Hijack()
if err != nil {
log.Print("rpc hijacking ", w.RemoteAddr(), ": ", err.String())
return