Module

asgi._scope

Shared scope-building logic for HTTP and WebSocket ASGI bridges.

Extracts the common target parsing, path decoding, and header conversion used by all three bridges (HTTP/1.1, HTTP/2, WebSocket).

Functions

build_base_scope 8 dict[str, Any]
Build the common ASGI scope fields shared across all protocols.
def build_base_scope(request: RequestReceived, *, scope_type: str, http_version: str, scheme: str, server: tuple[str, int], client: tuple[str, int], root_path: str, extensions: dict[str, Any] | None = None) -> dict[str, Any]
Parameters
Name Type Description
request RequestReceived

Parsed HTTP request head.

scope_type str

ASGI scope type ("http" or "websocket").

http_version str

Protocol version string ("1.1", "2").

scheme str

URL scheme ("http", "https", "ws", "wss").

server tuple[str, int]

Local(host, port)tuple.

client tuple[str, int]

Remote(host, port)tuple.

root_path str

ASGI root_path for reverse proxy setups.

extensions dict[str, Any] | None

Optional ASGI extensions dict.

Default:None
Returns
dict[str, Any]