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

Method test_invalid_connection

tests/test_server.py:376–391  ·  view source on GitHub ↗

Handshake fails when the Connection header is invalid.

(self)

Source from the content-addressed store, hash-verified

374 )
375
376 def test_invalid_connection(self):
377 """Handshake fails when the Connection header is invalid."""
378 server = ServerProtocol()
379 request = make_request()
380 del request.headers["Connection"]
381 request.headers["Connection"] = "close"
382 response = server.accept(request)
383 server.send_response(response)
384
385 self.assertEqual(response.status_code, 426)
386 self.assertEqual(response.headers["Upgrade"], "websocket")
387 self.assertHandshakeError(
388 server,
389 InvalidUpgrade,
390 "invalid Connection header: close",
391 )
392
393 def test_missing_upgrade(self):
394 """Handshake fails when the Upgrade header is missing."""

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