blackbull.server.http2_ws¶
blackbull.server.http2_ws
¶
HTTP/2 WebSocket byte-stream adapters (RFC 8441).
HTTP2WSReader and HTTP2WSWriter bridge between the HTTP/2 DATA frame layer and the RFC 6455 WebSocket codec (ws_codec.py).
HTTP2WSReader — AbstractReader backed by DATA frame payloads pushed by HTTP2Actor._on_data_frame(). Implements the same put_DATAFrame / put_disconnect interface as HTTP2Recipient so the existing _signal_recipients() helper and _on_data_frame() dispatch work without modification.
HTTP2WSWriter — AbstractWriter that wraps an HTTP2Sender and translates raw WebSocket frame bytes into http.response.body events (inheriting HTTP/2 flow control from the sender). close() sends a final empty DATA+END_STREAM to signal orderly HTTP/2 stream termination per RFC 8441 §5.
HTTP2WSReader
¶
Bases: AbstractReader
Byte-buffer AbstractReader fed by HTTP/2 DATA frames.
ws_codec.read_frame_header / read_payload call readexactly(n); this class buffers raw DATA frame payloads and serves exact-length reads, blocking until enough bytes arrive or EOF is signalled.
Backpressure: when the buffered byte count crosses
max_buffer, put_DATAFrame returns False to signal the
HTTP/2 actor to skip the per-frame WINDOW_UPDATE emission. The
bytes are still buffered (the peer's window debited on the wire
the moment the frame arrived; dropping them would be silent data
loss). As soon as :meth:readexactly drains the buffer back under
max_buffer, the reader replays the withheld credit through
credit_callback, opening the peer's window again.
put_DATAFrame(frame)
¶
Buffer payload bytes from an incoming DATA frame.
Always buffers (no silent drop — the peer's window already
debited frame.length when the frame hit the wire). Returns
True when the buffer remained under max_buffer after the
append; False when the cap was exceeded. In the False
case the actor must skip the per-frame WINDOW_UPDATE — the
bytes are queued for credit replay via readexactly.
put_disconnect()
¶
Signal EOF (connection closed or GOAWAY received).
HTTP2WSWriter
¶
Bases: AbstractWriter
AbstractWriter that sends WebSocket frame bytes as HTTP/2 DATA frames.
Delegates to an HTTP2Sender so HTTP/2 flow control (RFC 7540 §6.9) is honoured transparently. close() sends an empty DATA+END_STREAM to signal orderly HTTP/2 stream termination (RFC 8441 §5).