HTTP scope and messages¶
Use these mappings for the HTTP scope and the request and response events exchanged with an ASGI application.
HTTPScope¶
Bases: TypedDict
An HTTP request scope in Scope.
typeinstance-attribute¶
type: Literal['http']
asgiinstance-attribute¶
asgi: HTTPASGIVersions
http_versioninstance-attribute¶
http_version: Literal['1.1', '2']
methodinstance-attribute¶
method: str
schemeinstance-attribute¶
scheme: str
pathinstance-attribute¶
path: str
raw_pathinstance-attribute¶
raw_path: bytes
query_stringinstance-attribute¶
query_string: bytes
root_pathinstance-attribute¶
root_path: NotRequired[str]
headersinstance-attribute¶
headers: ScopeHeaders
clientinstance-attribute¶
client: NotRequired[tuple[str, int]]
serverinstance-attribute¶
server: tuple[str, int | None]
extensionsinstance-attribute¶
extensions: HTTPExtensions
HTTPRequest¶
Bases: TypedDict
An HTTP request event in ReceiveMessage.
HTTPDisconnect¶
Bases: TypedDict
An HTTP disconnect event in ReceiveMessage.
typeinstance-attribute¶
type: Literal['http.disconnect']
HTTPResponseStart¶
HTTPResponseBody¶
Bases: TypedDict
An HTTP response-body event in SendMessage.
HTTPResponseTrailers¶
Bases: TypedDict
An HTTP response-trailers event in SendMessage.
HTTPResponsePathsend¶
Bases: TypedDict
An HTTP path-send event in SendMessage.
HTTPResponseZeroCopySend¶
Bases: TypedDict
A response body segment in SendMessage, read straight from an open file.
Sent after http.response.start, as many times as wanted, and freely interleaved with http.response.body. offset defaults to the descriptor's current position and count to the rest of the file.
The descriptor stays yours: this server duplicates it and closes only the duplicate, so closing it as soon as send() returns is safe -- and, per the ASGI specification, your responsibility.
HTTPResponseEarlyHint¶
Bases: TypedDict
An RFC 8297 103 Early Hints interim response in SendMessage.
Sent after http.response.start and before the final body, as many times as wanted. Each value becomes one link field; ordering and duplicates are preserved. Offered only on HTTP/2 -- check scope["extensions"].