Commit 73fd9e7d authored by Tarmigan Casebolt's avatar Tarmigan Casebolt Committed by Russ Cox

websocket: Fix infinite recursion in WebSockAddr String()

String() is already inherited from the embedded *url.URL

R=ukai, adg, rsc
CC=golang-dev
https://golang.org/cl/4992049
parent 3e42de29
......@@ -65,9 +65,6 @@ type WebSocketAddr struct {
// Network returns the network type for a WebSocket, "websocket".
func (addr WebSocketAddr) Network() string { return "websocket" }
// String returns the network address for a WebSocket.
func (addr WebSocketAddr) String() string { return addr.String() }
// Config is a WebSocket configuration
type Config struct {
// A WebSocket server address.
......
......@@ -87,6 +87,31 @@ func TestEcho(t *testing.T) {
conn.Close()
}
func TestAddr(t *testing.T) {
once.Do(startServer)
// websocket.Dial()
client, err := net.Dial("tcp", serverAddr)
if err != nil {
t.Fatal("dialing", err)
}
conn, err := NewClient(newConfig(t, "/echo"), client)
if err != nil {
t.Errorf("WebSocket handshake error: %v", err)
return
}
ra := conn.RemoteAddr().String()
if !strings.HasPrefix(ra, "ws://") || !strings.HasSuffix(ra, "/echo") {
t.Errorf("Bad remote addr: %v", ra)
}
la := conn.LocalAddr().String()
if !strings.HasPrefix(la, "http://") {
t.Errorf("Bad local addr: %v", la)
}
conn.Close()
}
func TestCount(t *testing.T) {
once.Do(startServer)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment