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

Function default_handler

tests/legacy/test_client_server.py:50–69  ·  view source on GitHub ↗
(ws)

Source from the content-addressed store, hash-verified

48
49
50async def default_handler(ws):
51 if ws.path == "/deprecated_attributes":
52 await ws.recv() # delay that allows catching warnings
53 await ws.send(repr((ws.host, ws.port, ws.secure)))
54 elif ws.path == "/close_timeout":
55 await ws.send(repr(ws.close_timeout))
56 elif ws.path == "/path":
57 await ws.send(str(ws.path))
58 elif ws.path == "/headers":
59 await ws.send(repr(ws.request_headers))
60 await ws.send(repr(ws.response_headers))
61 elif ws.path == "/extensions":
62 await ws.send(repr(ws.extensions))
63 elif ws.path == "/subprotocol":
64 await ws.send(repr(ws.subprotocol))
65 elif ws.path == "/slow_stop":
66 await ws.wait_closed()
67 await asyncio.sleep(2 * MS)
68 else:
69 await ws.send(await ws.recv())
70
71
72async def redirect_request(path, headers, test, status):

Callers

nothing calls this directly

Calls 3

recvMethod · 0.45
sendMethod · 0.45
wait_closedMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…