From 2168e6aaf1a1f6117f2523e4c4b1fcc0a117b81f Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Mon, 7 Mar 2011 12:04:04 -0800 Subject: [PATCH] http: change Hijacker to return a net.Conn net.Conn is itself a io.ReadWriteCloser, so most code should be unaffected. R=rsc, gburd CC=golang-dev https://golang.org/cl/4261052 --- src/pkg/http/server.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/pkg/http/server.go b/src/pkg/http/server.go index 5d623e696b..428d9446e2 100644 --- a/src/pkg/http/server.go +++ b/src/pkg/http/server.go @@ -83,24 +83,25 @@ type ResponseWriter interface { Flush() } -// A Hijacker is an HTTP request which be taken over by an HTTP handler. +// The Hijacker interface is implemented by ResponseWriters that allow +// an HTTP handler to take over the connection. type Hijacker interface { // Hijack lets the caller take over the connection. // After a call to Hijack(), the HTTP server library // will not do anything else with the connection. // It becomes the caller's responsibility to manage // and close the connection. - Hijack() (io.ReadWriteCloser, *bufio.ReadWriter, os.Error) + Hijack() (net.Conn, *bufio.ReadWriter, os.Error) } // A conn represents the server side of an HTTP connection. type conn struct { - remoteAddr string // network address of remote side - handler Handler // request handler - rwc io.ReadWriteCloser // i/o connection - buf *bufio.ReadWriter // buffered rwc - hijacked bool // connection has been hijacked by handler - usingTLS bool // a flag indicating connection over TLS + remoteAddr string // network address of remote side + handler Handler // request handler + rwc net.Conn // i/o connection + buf *bufio.ReadWriter // buffered rwc + hijacked bool // connection has been hijacked by handler + usingTLS bool // a flag indicating connection over TLS } // A response represents the server side of an HTTP response. @@ -475,8 +476,9 @@ func (c *conn) serve() { c.close() } -// Hijack impements the ResponseWriter.Hijack method. -func (w *response) Hijack() (rwc io.ReadWriteCloser, buf *bufio.ReadWriter, err os.Error) { +// Hijack implements the Hijacker.Hijack method. Our response is both a ResponseWriter +// and a Hijacker. +func (w *response) Hijack() (rwc net.Conn, buf *bufio.ReadWriter, err os.Error) { if w.conn.hijacked { return nil, nil, ErrHijacked } -- 2.50.0