hypercorn.typing module

class hypercorn.typing.ASGI2Protocol(*args, **kwargs)

Bases: Protocol

class hypercorn.typing.ASGIVersions

Bases: TypedDict

spec_version: str
version: Union[Literal[2.0], Literal[3.0]]
class hypercorn.typing.Context(*args, **kwargs)

Bases: Protocol

event_class: Type[hypercorn.typing.Event]
async static sleep(wait: Union[float, int])None
spawn(func: Callable, *args: Any)None
async spawn_app(app: Union[Type[hypercorn.typing.ASGI2Protocol], Callable[[Union[hypercorn.typing.HTTPScope, hypercorn.typing.WebsocketScope, hypercorn.typing.LifespanScope], Callable[], Awaitable[Union[hypercorn.typing.HTTPRequestEvent, hypercorn.typing.HTTPDisconnectEvent, hypercorn.typing.WebsocketConnectEvent, hypercorn.typing.WebsocketReceiveEvent, hypercorn.typing.WebsocketDisconnectEvent, hypercorn.typing.LifespanStartupEvent, hypercorn.typing.LifespanShutdownEvent]]], Callable[[Union[hypercorn.typing.HTTPResponseStartEvent, hypercorn.typing.HTTPResponseBodyEvent, hypercorn.typing.HTTPServerPushEvent, hypercorn.typing.HTTPDisconnectEvent, hypercorn.typing.WebsocketAcceptEvent, hypercorn.typing.WebsocketSendEvent, hypercorn.typing.WebsocketResponseStartEvent, hypercorn.typing.WebsocketResponseBodyEvent, hypercorn.typing.WebsocketCloseEvent, hypercorn.typing.LifespanStartupCompleteEvent, hypercorn.typing.LifespanStartupFailedEvent, hypercorn.typing.LifespanShutdownCompleteEvent, hypercorn.typing.LifespanShutdownFailedEvent]], Awaitable[None]]], Awaitable[None]]], config: hypercorn.config.Config, scope: Union[hypercorn.typing.HTTPScope, hypercorn.typing.WebsocketScope, hypercorn.typing.LifespanScope], send: Callable[[Optional[Union[hypercorn.typing.HTTPResponseStartEvent, hypercorn.typing.HTTPResponseBodyEvent, hypercorn.typing.HTTPServerPushEvent, hypercorn.typing.HTTPDisconnectEvent, hypercorn.typing.WebsocketAcceptEvent, hypercorn.typing.WebsocketSendEvent, hypercorn.typing.WebsocketResponseStartEvent, hypercorn.typing.WebsocketResponseBodyEvent, hypercorn.typing.WebsocketCloseEvent, hypercorn.typing.LifespanStartupCompleteEvent, hypercorn.typing.LifespanStartupFailedEvent, hypercorn.typing.LifespanShutdownCompleteEvent, hypercorn.typing.LifespanShutdownFailedEvent]]], Awaitable[None]])Callable[[Union[hypercorn.typing.HTTPRequestEvent, hypercorn.typing.HTTPDisconnectEvent, hypercorn.typing.WebsocketConnectEvent, hypercorn.typing.WebsocketReceiveEvent, hypercorn.typing.WebsocketDisconnectEvent, hypercorn.typing.LifespanStartupEvent, hypercorn.typing.LifespanShutdownEvent]], Awaitable[None]]
static time()float
class hypercorn.typing.Event(*args, **kwargs)

Bases: Protocol

async clear()None
async set()None
async wait()None
class hypercorn.typing.H2AsyncStream(*args, **kwargs)

Bases: Protocol

async close()None
async data_received(data: bytes)None
async ended()None
async handle_request(event: h2.events.RequestReceived, scheme: str, client: Tuple[str, int], server: Tuple[str, int])None
async reset()None
scope: dict
class hypercorn.typing.H2SyncStream(*args, **kwargs)

Bases: Protocol

close()None
data_received(data: bytes)None
ended()None
async handle_request(event: h2.events.RequestReceived, scheme: str, client: Tuple[str, int], server: Tuple[str, int])None
reset()None
scope: dict
class hypercorn.typing.HTTPDisconnectEvent

Bases: TypedDict

type: Literal[http.disconnect]
class hypercorn.typing.HTTPRequestEvent

Bases: TypedDict

body: bytes
more_body: bool
type: Literal[http.request]
class hypercorn.typing.HTTPResponseBodyEvent

Bases: TypedDict

body: bytes
more_body: bool
type: Literal[http.response.body]
class hypercorn.typing.HTTPResponseStartEvent

Bases: TypedDict

headers: Iterable[Tuple[bytes, bytes]]
status: int
type: Literal[http.response.start]
class hypercorn.typing.HTTPScope

Bases: TypedDict

asgi: hypercorn.typing.ASGIVersions
client: Optional[Tuple[str, int]]
extensions: Dict[str, dict]
headers: Iterable[Tuple[bytes, bytes]]
http_version: str
method: str
path: str
query_string: bytes
raw_path: bytes
root_path: str
scheme: str
server: Optional[Tuple[str, Optional[int]]]
type: Literal[http]
class hypercorn.typing.HTTPServerPushEvent

Bases: TypedDict

headers: Iterable[Tuple[bytes, bytes]]
path: str
type: Literal[http.response.push]
class hypercorn.typing.LifespanScope

Bases: TypedDict

asgi: hypercorn.typing.ASGIVersions
type: Literal[lifespan]
class hypercorn.typing.LifespanShutdownCompleteEvent

Bases: TypedDict

type: Literal[lifespan.shutdown.complete]
class hypercorn.typing.LifespanShutdownEvent

Bases: TypedDict

type: Literal[lifespan.shutdown]
class hypercorn.typing.LifespanShutdownFailedEvent

Bases: TypedDict

message: str
type: Literal[lifespan.shutdown.failed]
class hypercorn.typing.LifespanStartupCompleteEvent

Bases: TypedDict

type: Literal[lifespan.startup.complete]
class hypercorn.typing.LifespanStartupEvent

Bases: TypedDict

type: Literal[lifespan.startup]
class hypercorn.typing.LifespanStartupFailedEvent

Bases: TypedDict

message: str
type: Literal[lifespan.startup.failed]
class hypercorn.typing.ResponseSummary

Bases: TypedDict

headers: Iterable[Tuple[bytes, bytes]]
status: int
class hypercorn.typing.WebsocketAcceptEvent

Bases: TypedDict

headers: Iterable[Tuple[bytes, bytes]]
subprotocol: Optional[str]
type: Literal[websocket.accept]
class hypercorn.typing.WebsocketCloseEvent

Bases: TypedDict

code: int
type: Literal[websocket.close]
class hypercorn.typing.WebsocketConnectEvent

Bases: TypedDict

type: Literal[websocket.connect]
class hypercorn.typing.WebsocketDisconnectEvent

Bases: TypedDict

code: int
type: Literal[websocket.disconnect]
class hypercorn.typing.WebsocketReceiveEvent

Bases: TypedDict

bytes: Optional[bytes]
text: Optional[str]
type: Literal[websocket.receive]
class hypercorn.typing.WebsocketResponseBodyEvent

Bases: TypedDict

body: bytes
more_body: bool
type: Literal[websocket.http.response.body]
class hypercorn.typing.WebsocketResponseStartEvent

Bases: TypedDict

headers: Iterable[Tuple[bytes, bytes]]
status: int
type: Literal[websocket.http.response.start]
class hypercorn.typing.WebsocketScope

Bases: TypedDict

asgi: hypercorn.typing.ASGIVersions
client: Optional[Tuple[str, int]]
extensions: Dict[str, dict]
headers: Iterable[Tuple[bytes, bytes]]
http_version: str
path: str
query_string: bytes
raw_path: bytes
root_path: str
scheme: str
server: Optional[Tuple[str, Optional[int]]]
subprotocols: Iterable[str]
type: Literal[websocket]
class hypercorn.typing.WebsocketSendEvent

Bases: TypedDict

bytes: Optional[bytes]
text: Optional[str]
type: Literal[websocket.send]