websocket: use URL.RawPath to construct WebSocket-Location: header

R=rsc
CC=golang-dev
https://golang.org/cl/651041
This commit is contained in:
Fumitoshi Ukai 2010-03-19 14:18:02 -07:00 committed by Russ Cox
parent 71e402d8ff
commit f15447ca3e
2 changed files with 18 additions and 1 deletions

View 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.

View 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)