]> Cypherpunks repositories - gostls13.git/commitdiff
websocket: include *http.Request in websocket.Conn
authorAndrew Gerrand <adg@golang.org>
Tue, 26 Apr 2011 00:47:49 +0000 (10:47 +1000)
committerAndrew Gerrand <adg@golang.org>
Tue, 26 Apr 2011 00:47:49 +0000 (10:47 +1000)
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

src/pkg/websocket/server.go
src/pkg/websocket/websocket.go

index 1119b2d34ebdf906e14f0a96e962a891352d09c5..376265236e228d1cd8a8627c25d8e5161c4ba908 100644 (file)
@@ -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)
 }
 
index eaad22eb33603a20b82a4942dd07d16701fe4c53..edde61b4a762d97ee7ca291e7166ccf79f9855b4 100644 (file)
@@ -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