From 9ff56c9570642711d5b7ab29920ecf5dbff14a27 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 20 May 2011 00:18:15 +0000 Subject: Update to current version of Go library. From-SVN: r173931 --- libgo/go/websocket/server.go | 1 + libgo/go/websocket/websocket.go | 5 ++++- libgo/go/websocket/websocket_test.go | 7 ++++--- 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'libgo/go/websocket') diff --git a/libgo/go/websocket/server.go b/libgo/go/websocket/server.go index 1119b2d34eb..376265236e2 100644 --- a/libgo/go/websocket/server.go +++ b/libgo/go/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/libgo/go/websocket/websocket.go b/libgo/go/websocket/websocket.go index d5996abe1a5..edde61b4a76 100644 --- a/libgo/go/websocket/websocket.go +++ b/libgo/go/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/libgo/go/websocket/websocket_test.go b/libgo/go/websocket/websocket_test.go index 8b3cf8925a9..10f88dfd1a0 100644 --- a/libgo/go/websocket/websocket_test.go +++ b/libgo/go/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() } } -- cgit v1.2.1