flare_mlake · API · ws

flare.ws.client_h3

Client side of WebSocket over HTTP/3 (RFC 9220).

:class:WsOverH3Stream opens an extended CONNECT (:protocol: websocket) request stream on an :class:flare.http3.Http3ClientConnection and carries WebSocket frames in its DATA frames: masked from the client (RFC 6455 sec 5.3), and refused if the server masks.

Structs

WsOverH3Stream

struct WsOverH3Stream

Implements Movable

Fields
stream_id: UInt64
read_buffer: List[UInt8]
closed: Bool
max_frame_size: Int

__init__

def __init__(out self, stream_id: UInt64)

open

def open(mut h3: Http3ClientConnection, authority: String, path: String, timeout_ms: Int = Int(5000)) -> Self

Open the tunnel: wait for the server's SETTINGS, which must enable extended CONNECT (RFC 9220 sec 3), send the CONNECT and require a 200.

send_frame

def send_frame(mut self, mut h3: Http3ClientConnection, frame: WsFrame)

Send frame masked; a CLOSE frame ends our sending.

try_pull_frame

def try_pull_frame(mut self, mut h3: Http3ClientConnection, timeout_ms: Int = Int(100)) -> Optional[WsFrame]

The next server frame, or None until one has arrived.

close

def close(mut self, mut h3: Http3ClientConnection, code: UInt16 = UInt16(1000))

Send CLOSE and end the stream.