Skip to content

Stream API

stream

High-level abstractions for WebTransport streams.

StreamDiagnostics dataclass

Encapsulate stream diagnostic data.

WebTransportReceiveStream

Manage the readable side of a WebTransport stream.

can_read property

can_read: bool

Return True if the stream is readable.

direction property

direction: StreamDirection

Return the directionality of the stream.

close async

close() -> None

Terminate the receiving side of the stream.

read async

read(*, max_bytes: int = -1) -> bytes

Read data from the stream.

read_all async

read_all() -> bytes

Read all data from the stream until EOF.

readexactly async

readexactly(*, n: int) -> bytes

Read exactly n bytes from the stream.

readline async

readline(*, limit: int = -1) -> bytes

Read a line from the stream.

readuntil async

readuntil(*, separator: bytes, limit: int = -1) -> bytes

Read data from the stream until a separator is found.

stop_receiving async

stop_receiving(*, error_code: int = ErrorCodes.APP_NO_ERROR) -> None

Signal the peer to stop sending data.

WebTransportSendStream

Manage the writable side of a WebTransport stream.

can_write property

can_write: bool

Return True if the stream is writable.

direction property

direction: StreamDirection

Return the directionality of the stream.

close async

close(*, error_code: int | None = None) -> None

Terminate the sending side of the stream.

reset async

reset(*, error_code: int = ErrorCodes.APP_NO_ERROR) -> None

Abruptly terminate stream transmission.

write async

write(*, data: Buffer, end_stream: bool = False) -> None

Write data to the stream.

write_all async

write_all(*, data: Buffer, chunk_size: int = 65536, end_stream: bool = False) -> None

Write buffer data to the stream in chunks.

WebTransportStream

Manage the bidirectional WebTransport stream.

can_read property

can_read: bool

Return True if the stream is readable.

can_write property

can_write: bool

Return True if the stream is writable.

direction property

direction: StreamDirection

Return the directionality of the stream.

close async

close(*, error_code: int | None = None) -> None

Terminate both sides of the stream.

read async

read(*, max_bytes: int = -1) -> bytes

Read data from the stream.

read_all async

read_all() -> bytes

Read all data from the stream until EOF.

readexactly async

readexactly(*, n: int) -> bytes

Read exactly n bytes from the stream.

readline async

readline(*, limit: int = -1) -> bytes

Read a line from the stream.

readuntil async

readuntil(*, separator: bytes, limit: int = -1) -> bytes

Read data from the stream until a separator is found.

reset async

reset(*, error_code: int = ErrorCodes.APP_NO_ERROR) -> None

Stop sending data and reset the stream.

stop_receiving async

stop_receiving(*, error_code: int = ErrorCodes.APP_NO_ERROR) -> None

Signal the peer to stop sending data.

write async

write(*, data: Buffer, end_stream: bool = False) -> None

Write data to the stream.

write_all async

write_all(*, data: Buffer, chunk_size: int = 65536, end_stream: bool = False) -> None

Write buffer data to the stream in chunks.