Skip to content

Session API

session

High-level abstraction for a WebTransport session.

SessionDiagnostics dataclass

Encapsulate session diagnostic data.

WebTransportSession

Manage the high-level WebTransport session.

headers property

headers: Headers

Return the initial request headers for this session.

is_closed property

is_closed: bool

Return True if the session is closed.

path property

path: str

Return the request path associated with this session.

remote_address property

remote_address: Address | None

Return the remote address of the peer.

session_id property

session_id: SessionId

Return the unique identifier for this session.

state property

state: SessionState

Return the current state of the session.

wt_available_protocols property

wt_available_protocols: list[str] | None

Return the wt_available_protocols requested by the client.

wt_protocol property writable

wt_protocol: str | None

Return the negotiated wt_protocol for this session.

accept async

accept() -> None

Accept the incoming WebTransport session request.

accept_bidirectional_stream async

accept_bidirectional_stream() -> WebTransportStream

Accept the next incoming bidirectional stream.

accept_unidirectional_stream async

accept_unidirectional_stream() -> WebTransportReceiveStream

Accept the next incoming unidirectional stream.

close async

close(*, error_code: int = ErrorCodes.APP_NO_ERROR, reason: str | None = None) -> None

Terminate the WebTransport session.

create_bidirectional_stream async

create_bidirectional_stream() -> WebTransportStream

Instantiate a new bidirectional WebTransport stream.

create_unidirectional_stream async

create_unidirectional_stream() -> WebTransportSendStream

Instantiate a new unidirectional WebTransport stream.

diagnostics async

diagnostics() -> SessionDiagnostics

Retrieve diagnostic information about the session.

export_keying_material async

export_keying_material(*, label: str, context: Buffer, length: int) -> bytes

Export TLS keying material for this session.

grant_data_credit async

grant_data_credit(*, max_data: int) -> None

Allocate data flow control credit to the peer.

grant_streams_credit async

grant_streams_credit(*, is_unidirectional: bool, max_streams: int) -> None

Allocate stream flow control credit to the peer.

incoming_bidirectional_streams async

incoming_bidirectional_streams() -> AsyncGenerator[WebTransportStream, None]

Yield incoming bidirectional streams until the session is closed.

incoming_unidirectional_streams async

incoming_unidirectional_streams() -> AsyncGenerator[WebTransportReceiveStream, None]

Yield incoming unidirectional streams until the session is closed.

reject async

reject(*, status_code: int = http.HTTPStatus.FORBIDDEN) -> None

Reject the incoming WebTransport session request.

send_datagram async

send_datagram(*, data: Buffer) -> None

Transmit an unreliable datagram.