MCPcopy
hub / github.com/gorilla/websocket / TestHandshake

Function TestHandshake

client_server_test.go:502–526  ·  client_server_test.go::TestHandshake
(t *testing.T)

Source from the content-addressed store, hash-verified

500}
501
502func 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
528func TestRespOnBadHandshake(t *testing.T) {
529 const expectedStatus = http.StatusGone

Callers

nothing calls this directly

Calls 6

newServerFunction · 0.85
sendRecvFunction · 0.85
SubprotocolMethod · 0.80
DialMethod · 0.65
CloseMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected