OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package websocket | 5 package websocket |
6 | 6 |
7 import ( | 7 import ( |
8 "bytes" | 8 "bytes" |
9 "fmt" | 9 "fmt" |
10 "io" | 10 "io" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 | 157 |
158 func TestWithQuery(t *testing.T) { | 158 func TestWithQuery(t *testing.T) { |
159 once.Do(startServer) | 159 once.Do(startServer) |
160 | 160 |
161 client, err := net.Dial("tcp", serverAddr) | 161 client, err := net.Dial("tcp", serverAddr) |
162 if err != nil { | 162 if err != nil { |
163 t.Fatal("dialing", err) | 163 t.Fatal("dialing", err) |
164 } | 164 } |
165 | 165 |
166 config := newConfig(t, "/echo") | 166 config := newConfig(t, "/echo") |
167 » config.Location, err = url.ParseRequest(fmt.Sprintf("ws://%s/echo?q=v",
serverAddr)) | 167 » config.Location, err = url.ParseRequestURI(fmt.Sprintf("ws://%s/echo?q=v
", serverAddr)) |
168 if err != nil { | 168 if err != nil { |
169 t.Fatal("location url", err) | 169 t.Fatal("location url", err) |
170 } | 170 } |
171 | 171 |
172 ws, err := NewClient(config, client) | 172 ws, err := NewClient(config, client) |
173 if err != nil { | 173 if err != nil { |
174 t.Errorf("WebSocket handshake: %v", err) | 174 t.Errorf("WebSocket handshake: %v", err) |
175 return | 175 return |
176 } | 176 } |
177 ws.Close() | 177 ws.Close() |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 n, err = conn.Read(second_msg) | 265 n, err = conn.Read(second_msg) |
266 if err != nil { | 266 if err != nil { |
267 t.Errorf("Read: %v", err) | 267 t.Errorf("Read: %v", err) |
268 } | 268 } |
269 second_msg = second_msg[0:n] | 269 second_msg = second_msg[0:n] |
270 if !bytes.Equal(msg[len(small_msg):], second_msg) { | 270 if !bytes.Equal(msg[len(small_msg):], second_msg) { |
271 t.Errorf("Echo: expected %q got %q", msg[len(small_msg):], secon
d_msg) | 271 t.Errorf("Echo: expected %q got %q", msg[len(small_msg):], secon
d_msg) |
272 } | 272 } |
273 conn.Close() | 273 conn.Close() |
274 } | 274 } |
OLD | NEW |