diff options
author | Andrew Gerrand <adg@golang.org> | 2011-04-26 10:47:49 +1000 |
---|---|---|
committer | Andrew Gerrand <adg@golang.org> | 2011-04-26 10:47:49 +1000 |
commit | 43b97ce69bdf417c64e639399921a655ca39baea (patch) | |
tree | 25b192afe4a1b865d168a2a0d28214f66559cc16 | |
parent | 079a5cffb3f541920b28dabbe777a0dee5d6f32a (diff) | |
download | go-43b97ce69bdf417c64e639399921a655ca39baea.tar.gz go-43b97ce69bdf417c64e639399921a655ca39baea.zip |
websocket: include *http.Request in websocket.Conn
This permits the websocket handler to inspect http headers and such.
Fixes #1726.
R=ukai, bradfitz, bradfitzgo
CC=golang-dev
https://golang.org/cl/4439069
-rw-r--r-- | src/pkg/websocket/server.go | 1 | ||||
-rw-r--r-- | src/pkg/websocket/websocket.go | 3 |
2 files changed, 4 insertions, 0 deletions
diff --git a/src/pkg/websocket/server.go b/src/pkg/websocket/server.go index 1119b2d34e..376265236e 100644 --- a/src/pkg/websocket/server.go +++ b/src/pkg/websocket/server.go @@ -150,6 +150,7 @@ func (f Handler) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } ws := newConn(origin, location, protocol, buf, rwc) + ws.Request = req f(ws) } diff --git a/src/pkg/websocket/websocket.go b/src/pkg/websocket/websocket.go index eaad22eb33..edde61b4a7 100644 --- a/src/pkg/websocket/websocket.go +++ b/src/pkg/websocket/websocket.go @@ -13,6 +13,7 @@ import ( "bufio" "crypto/md5" "encoding/binary" + "http" "io" "net" "os" @@ -43,6 +44,8 @@ type Conn struct { Location string // The subprotocol for the Web Socket. Protocol string + // The initial http Request (for the Server side only). + Request *http.Request buf *bufio.ReadWriter rwc io.ReadWriteCloser |