summaryrefslogtreecommitdiff
path: root/src/pkg/websocket
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-04-28 10:35:15 +0200
committerOndřej Surý <ondrej@sury.org>2011-04-28 10:35:15 +0200
commitc1ba1a0fec4aed430709030f98a3bdb90bfeea16 (patch)
tree3df18657e50a0313ed6defcda30e4474cb28a467 /src/pkg/websocket
parent7b15ed9ef455b6b66c6b376898a88aef5d6a9970 (diff)
downloadgolang-c1ba1a0fec4aed430709030f98a3bdb90bfeea16.tar.gz
Imported Upstream version 2011.04.27upstream/2011.04.27
Diffstat (limited to 'src/pkg/websocket')
-rw-r--r--src/pkg/websocket/server.go1
-rw-r--r--src/pkg/websocket/websocket.go5
-rw-r--r--src/pkg/websocket/websocket_test.go7
3 files changed, 9 insertions, 4 deletions
diff --git a/src/pkg/websocket/server.go b/src/pkg/websocket/server.go
index 1119b2d34..376265236 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 d5996abe1..edde61b4a 100644
--- a/src/pkg/websocket/websocket.go
+++ b/src/pkg/websocket/websocket.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// The websocket package implements a client and server for the Web Socket protocol.
+// Package websocket implements a client and server for the Web Socket protocol.
// The protocol is defined at http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol
package websocket
@@ -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
diff --git a/src/pkg/websocket/websocket_test.go b/src/pkg/websocket/websocket_test.go
index 8b3cf8925..10f88dfd1 100644
--- a/src/pkg/websocket/websocket_test.go
+++ b/src/pkg/websocket/websocket_test.go
@@ -186,11 +186,12 @@ func TestTrailingSpaces(t *testing.T) {
once.Do(startServer)
for i := 0; i < 30; i++ {
// body
- _, err := Dial(fmt.Sprintf("ws://%s/echo", serverAddr), "",
- "http://localhost/")
+ ws, err := Dial(fmt.Sprintf("ws://%s/echo", serverAddr), "", "http://localhost/")
if err != nil {
- panic("Dial failed: " + err.String())
+ t.Error("Dial failed:", err.String())
+ break
}
+ ws.Close()
}
}