Classes
BuiltinResponse
4
▼
A protocol-neutral response produced by a built-in endpoint.
BuiltinResponse
4
▼
A protocol-neutral response produced by a built-in endpoint.
Attributes
| Name | Type | Description |
|---|---|---|
kind |
Literal['health', 'introspection', 'dictionary']
|
— |
status |
int
|
— |
headers |
list[tuple[bytes, bytes]]
|
— |
body |
bytes
|
— |
Functions
is_trusted_peer
2
bool
▼
Check if the client address is in the trusted hosts set.
is_trusted_peer
2
bool
▼
def is_trusted_peer(config: ServerConfig, client_addr: str) -> bool
Parameters
| Name | Type | Description |
|---|---|---|
config |
ServerConfig |
|
client_addr |
str |
Returns
bool
prepare_request
5
tuple[dict[str, Any], st…
▼
Build ASGI scope, extract request ID, and set extensions.
Returns (scope, requ…
prepare_request
5
tuple[dict[str, Any], st…
▼
def prepare_request(request: RequestReceived, config: ServerConfig, client: tuple[str, int], server: tuple[str, int], lifespan_state: dict[str, Any]) -> tuple[dict[str, Any], str | None]
Build ASGI scope, extract request ID, and set extensions.
Returns (scope, request_id).
Parameters
| Name | Type | Description |
|---|---|---|
request |
RequestReceived |
|
config |
ServerConfig |
|
client |
tuple[str, int] |
|
server |
tuple[str, int] |
|
lifespan_state |
dict[str, Any] |
Returns
tuple[dict[str, Any], str | None]
Select and build a built-in endpoint response before ASGI dispatch.
Endpoint s…
def maybe_build_builtin_response(config: ServerConfig, method: str | bytes, path: str, *, worker_id: int, active_connections: _IntProvider, draining: _BoolProvider = False) -> BuiltinResponse | None
Select and build a built-in endpoint response before ASGI dispatch.
Endpoint selection is shared across every HTTP transport while response serialization remains protocol-owned. Providers are evaluated lazily so normal application requests do not acquire connection-count locks or call drain-state hooks on the latency-sensitive request path.
Parameters
| Name | Type | Description |
|---|---|---|
config |
ServerConfig |
|
method |
str | bytes |
|
path |
str |
|
worker_id |
int |
|
active_connections |
_IntProvider |
|
draining |
_BoolProvider |
Default:False
|
Returns
BuiltinResponse | None
Negotiate content-encoding compression from request headers.
Returns (compress…
def negotiate_compressor(config: ServerConfig, headers: Sequence[tuple[bytes, bytes]], *, request_target: str = '') -> tuple[Compressor | None, CompressionDictionary | None]
Negotiate content-encoding compression from request headers.
Returns (compressor, dictionary) — dictionary is non-None only when
dcz(dictionary-compressed zstd) encoding is selected.
Parameters
| Name | Type | Description |
|---|---|---|
config |
ServerConfig |
|
headers |
Sequence[tuple[bytes, bytes]] |
|
request_target |
str |
Default:''
|
Returns
tuple[Compressor | None, CompressionDictionary | None]
Negotiate compression from already-extracted header values.
Meta-keyed entry p…
def negotiate_compressor_from_meta(config: ServerConfig, accept_encoding: bytes | None, available_dictionary: bytes | None, *, request_target: str = '') -> tuple[Compressor | None, CompressionDictionary | None]
Negotiate compression from already-extracted header values.
Meta-keyed entry point for the sync-worker hot path: the caller passes the
accept-encoding and available-dictionaryvalues already pulled out
of _RequestMeta (no redundant header scan) plus the decoded request
target. Behaviour is identical to negotiate_compressor().
Returns (compressor, dictionary) — dictionary is non-None only when
dcz(dictionary-compressed zstd) encoding is selected.
Parameters
| Name | Type | Description |
|---|---|---|
config |
ServerConfig |
|
accept_encoding |
bytes | None |
|
available_dictionary |
bytes | None |
|
request_target |
str |
Default:''
|
Returns
tuple[Compressor | None, CompressionDictionary | None]
log_request
10
None
▼
Log an access log entry, respecting the access_log_filter.
log_request
10
None
▼
def log_request(config: ServerConfig, method: str, target: str, status: int, bytes_sent: int, duration_ms: float, client_str: str, *, http_version: str = '1.1', request_id: str | None = None, worker_id: int | None = None) -> None
Parameters
| Name | Type | Description |
|---|---|---|
config |
ServerConfig |
|
method |
str |
|
target |
str |
|
status |
int |
|
bytes_sent |
int |
|
duration_ms |
float |
|
client_str |
str |
|
http_version |
str |
Default:'1.1'
|
request_id |
str | None |
Default:None
|
worker_id |
int | None |
Default:None
|