Types - websockets 12.0 documentation

Hide navigation sidebar
Hide table of contents sidebar
Back to top
Toggle table of contents sidebar

# Types

websockets.typing.Data

  Types supported in a WebSocket message: `str` for a Text frame, `bytes` for a Binary.

  alias of `Union`[`str`, `bytes`]

websockets.typing.LoggerLike

  Types accepted where a `Logger` is expected.

  alias of `Union`[`Logger`, `LoggerAdapter`]

websockets.typing.StatusLike

  Types accepted where an `HTTPStatus` is expected.

  alias of `Union`[`HTTPStatus`, `int`]

websockets.typing.Origin = websockets.typing.Origin

  Value of a `Origin` header.

websockets.typing.Subprotocol = websockets.typing.Subprotocol

  Subprotocol in a `Sec-WebSocket-Protocol` header.

websockets.typing.ExtensionName = websockets.typing.ExtensionName

  Name of a WebSocket extension.

websockets.typing.ExtensionParameter

  Parameter of a WebSocket extension.

  alias of `Tuple`[`str`, `Optional`[`str`]]

websockets.protocol.Event

  Events that `events_received()` may return.

  alias of `Union`[`Request`, `Response`, `Frame`]

websockets.datastructures.HeadersLike

  Types accepted where `Headers` is expected.

  In addition to `Headers` itself, this includes dict-like types where both keys and values are `str`.

  alias of `Union`[`Headers`, `Mapping`[`str`, `str`], `Iterable`[`Tuple`[`str`, `str`]], `SupportsKeysAndGetItem`]

websockets.datastructures.SupportsKeysAndGetItem = <class 'websockets.datastructures.SupportsKeysAndGetItem'>

  Dict-like types with `keys() -> str` and `__getitem__(key: str) -> str` methods.