MCPcopy Index your code
hub / github.com/python-websockets/websockets / test_missing_key

Method test_missing_key

tests/test_server.py:426–439  ·  view source on GitHub ↗

Handshake fails when the Sec-WebSocket-Key header is missing.

(self)

Source from the content-addressed store, hash-verified

424 )
425
426 def test_missing_key(self):
427 """Handshake fails when the Sec-WebSocket-Key header is missing."""
428 server = ServerProtocol()
429 request = make_request()
430 del request.headers["Sec-WebSocket-Key"]
431 response = server.accept(request)
432 server.send_response(response)
433
434 self.assertEqual(response.status_code, 400)
435 self.assertHandshakeError(
436 server,
437 InvalidHeader,
438 "missing Sec-WebSocket-Key header",
439 )
440
441 def test_multiple_key(self):
442 """Handshake fails when the Sec-WebSocket-Key header is repeated."""

Callers

nothing calls this directly

Calls 5

acceptMethod · 0.95
send_responseMethod · 0.95
assertHandshakeErrorMethod · 0.95
ServerProtocolClass · 0.85
make_requestFunction · 0.85

Tested by

no test coverage detected