| 500 | } |
| 501 | |
| 502 | func TestHandshake(t *testing.T) { |
| 503 | s := newServer(t) |
| 504 | defer s.Close() |
| 505 | |
| 506 | ws, resp, err := cstDialer.Dial(s.URL, http.Header{"Origin": {s.URL}}) |
| 507 | if err != nil { |
| 508 | t.Fatalf("Dial: %v", err) |
| 509 | } |
| 510 | defer ws.Close() |
| 511 | |
| 512 | var sessionID string |
| 513 | for _, c := range resp.Cookies() { |
| 514 | if c.Name == "sessionID" { |
| 515 | sessionID = c.Value |
| 516 | } |
| 517 | } |
| 518 | if sessionID != "1234" { |
| 519 | t.Error("Set-Cookie not received from the server.") |
| 520 | } |
| 521 | |
| 522 | if ws.Subprotocol() != "p1" { |
| 523 | t.Errorf("ws.Subprotocol() = %s, want p1", ws.Subprotocol()) |
| 524 | } |
| 525 | sendRecv(t, ws) |
| 526 | } |
| 527 | |
| 528 | func TestRespOnBadHandshake(t *testing.T) { |
| 529 | const expectedStatus = http.StatusGone |