]> Cypherpunks repositories - gostls13.git/commitdiff
websocket: use URL.RawPath to construct WebSocket-Location: header
authorFumitoshi Ukai <ukai@google.com>
Fri, 19 Mar 2010 21:18:02 +0000 (14:18 -0700)
committerRuss Cox <rsc@golang.org>
Fri, 19 Mar 2010 21:18:02 +0000 (14:18 -0700)
R=rsc
CC=golang-dev
https://golang.org/cl/651041

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

index 0ccb31e8a22e7cb9f391734dc3755d6b2364671c..93d8b7afd287ac2da02fa2153b9be738862a4b04 100644 (file)
@@ -66,7 +66,7 @@ func (f Handler) ServeHTTP(c *http.Conn, req *http.Request) {
                return
        }
        defer rwc.Close()
-       location := "ws://" + req.Host + req.URL.Path
+       location := "ws://" + req.Host + req.URL.RawPath
 
        // TODO(ukai): verify origin,location,protocol.
 
index 44fda8aaafab99a4d9f617df525004101d18a0dc..92582b1ef2ea54c3a01242df955fed9aaf3aada4 100644 (file)
@@ -60,6 +60,23 @@ func TestEcho(t *testing.T) {
        ws.Close()
 }
 
+func TestWithQuery(t *testing.T) {
+       once.Do(startServer)
+
+       client, err := net.Dial("tcp", "", serverAddr)
+       if err != nil {
+               t.Fatal("dialing", err)
+       }
+
+       ws, err := newClient("/echo?q=v", "localhost", "http://localhost",
+               "ws://localhost/echo?q=v", "", client)
+       if err != nil {
+               t.Errorf("WebSocket handshake error", err)
+               return
+       }
+       ws.Close()
+}
+
 func TestHTTP(t *testing.T) {
        once.Do(startServer)