Functions
_get_header_from_tuple
2
bytes | None
▼
Get a header value by lowercase name from a headers tuple.
_get_header_from_tuple
2
bytes | None
▼
def _get_header_from_tuple(headers: tuple[tuple[bytes, bytes], ...], name: bytes) -> bytes | None
Parameters
| Name | Type | Description |
|---|---|---|
headers |
tuple[tuple[bytes, bytes], ...] |
|
name |
bytes |
Returns
bytes | None
handle_websocket
9
None
▼
Handle a WebSocket connection after HTTP/1.1 upgrade detection.
**Lifecycle:**…
async
handle_websocket
9
None
▼
async def handle_websocket(app: ASGIApp, config: ServerConfig, logger: logging.Logger, request: RequestReceived, reader: asyncio.StreamReader, writer: asyncio.StreamWriter, client: tuple[str, int], server: tuple[str, int], client_str: str) -> None
Handle a WebSocket connection after HTTP/1.1 upgrade detection.
Lifecycle:
- Build ASGI
websocketscope- Push
websocket.connectto the receive queue - Run the ASGI app — it sends
websocket.accept(or close) - Read WebSocket frames and feed to receive queue
- App sends
websocket.send/websocket.close - Clean up when either side disconnects
- Push
Parameters
| Name | Type | Description |
|---|---|---|
app |
ASGIApp |
The ASGI application callable. |
config |
ServerConfig |
Immutable server configuration. |
logger |
logging.Logger |
Logger scoped to the worker. |
request |
RequestReceived |
The parsed HTTP request that triggered the upgrade. |
reader |
asyncio.StreamReader |
Asyncio stream reader for the connection. |
writer |
asyncio.StreamWriter |
Asyncio stream writer for the connection. |
client |
tuple[str, int] |
|
server |
tuple[str, int] |
|
client_str |
str |
Formatted |