MCPcopy
hub / github.com/mitmproxy/mitmproxy / test_close_disconnect

Function test_close_disconnect

test/mitmproxy/proxy/layers/test_websocket.py:377–394  ·  view source on GitHub ↗
(ws_testdata)

Source from the content-addressed store, hash-verified

375
376
377def test_close_disconnect(ws_testdata):
378 tctx, playbook, flow = ws_testdata
379 assert (
380 playbook
381 << websocket.WebsocketStartHook(flow)
382 >> reply()
383 >> ConnectionClosed(tctx.server)
384 << CloseConnection(tctx.server)
385 << SendData(tctx.client, b"\x88\x02\x03\xe8")
386 << CloseConnection(tctx.client)
387 << websocket.WebsocketEndHook(flow)
388 >> reply()
389 >> ConnectionClosed(tctx.client)
390 )
391 # The \x03\xe8 above is code 1000 (normal closure).
392 # But 1006 (ABNORMAL_CLOSURE) is expected, because the connection was already closed.
393 assert flow.websocket.close_code == 1006
394 assert not flow.live
395
396
397def test_close_code(ws_testdata):

Callers

nothing calls this directly

Calls 4

replyClass · 0.90
ConnectionClosedClass · 0.90
CloseConnectionClass · 0.90
SendDataClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…