LEFT | RIGHT |
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 "bufio" | 8 "bufio" |
9 "bytes" | 9 "bytes" |
10 "fmt" | 10 "fmt" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 151 |
152 // If the client did not send a handshake that matches the protocol | 152 // If the client did not send a handshake that matches the protocol |
153 // specification, the server should abort the WebSocket connection. | 153 // specification, the server should abort the WebSocket connection. |
154 _, err := http.Get(fmt.Sprintf("http://%s/echo", serverAddr)) | 154 _, err := http.Get(fmt.Sprintf("http://%s/echo", serverAddr)) |
155 if err == nil { | 155 if err == nil { |
156 t.Error("Get: unexpected success") | 156 t.Error("Get: unexpected success") |
157 return | 157 return |
158 } | 158 } |
159 urlerr, ok := err.(*url.Error) | 159 urlerr, ok := err.(*url.Error) |
160 if !ok { | 160 if !ok { |
161 » » t.Errorf("Get: not URL Error %#v", err) | 161 » » t.Errorf("Get: not url.Error %#v", err) |
162 return | 162 return |
163 } | 163 } |
164 if urlerr.Error != io.ErrUnexpectedEOF { | 164 if urlerr.Error != io.ErrUnexpectedEOF { |
165 t.Errorf("Get: error %#v", err) | 165 t.Errorf("Get: error %#v", err) |
166 return | 166 return |
167 } | 167 } |
168 } | 168 } |
169 | 169 |
170 func TestHTTPDraft75(t *testing.T) { | 170 func TestHTTPDraft75(t *testing.T) { |
171 once.Do(startServer) | 171 once.Do(startServer) |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 ws := newConn("http://127.0.0.1/", "ws://127.0.0.1/", "", bufio.NewReadW
riter(br, bw), nil) | 262 ws := newConn("http://127.0.0.1/", "ws://127.0.0.1/", "", bufio.NewReadW
riter(br, bw), nil) |
263 msg := make([]byte, 5) | 263 msg := make([]byte, 5) |
264 n, err := ws.Read(msg) | 264 n, err := ws.Read(msg) |
265 if err != nil { | 265 if err != nil { |
266 t.Errorf("Read: %v", err) | 266 t.Errorf("Read: %v", err) |
267 } | 267 } |
268 if !bytes.Equal(b[4:8], msg[0:n]) { | 268 if !bytes.Equal(b[4:8], msg[0:n]) { |
269 t.Errorf("Read: expected %q got %q", msg[4:8], msg[0:n]) | 269 t.Errorf("Read: expected %q got %q", msg[4:8], msg[0:n]) |
270 } | 270 } |
271 } | 271 } |
LEFT | RIGHT |