Classes
H1Protocol
9
▼
HTTP/1.1 protocol handler backed by h11.
Implements the ProtocolHandler contract. Each instance ma…
H1Protocol
9
▼
HTTP/1.1 protocol handler backed by h11.
Implements the ProtocolHandler contract. Each instance manages a single TCP connection through one or more request-response cycles (keep-alive).
Methods
their_state
0
Any
▼
Current h11 client-side state (for diagnostics).
property
their_state
0
Any
▼
def their_state(self) -> Any
Returns
Any
our_state
0
Any
▼
Current h11 server-side state (for diagnostics).
property
our_state
0
Any
▼
def our_state(self) -> Any
Returns
Any
client_is_waiting_for_100_continue
0
bool
▼
True if the client sent Expect: 100-continue.
property
client_is_waiting_for_100_continue
0
bool
▼
def client_is_waiting_for_100_continue(self) -> bool
Returns
bool
receive_data
1
list[ProtocolEvent]
▼
Feed raw bytes from the socket, return parsed protocol events.
receive_data
1
list[ProtocolEvent]
▼
def receive_data(self, data: bytes) -> list[ProtocolEvent]
Parameters
| Name | Type | Description |
|---|---|---|
data |
— |
Raw bytes received from the network. |
Returns
list[ProtocolEvent]
List of protocol events parsed from the input.
send_response
2
bytes
▼
Serialize a response status line and headers into bytes.
send_response
2
bytes
▼
def send_response(self, status: int, headers: list[tuple[bytes, bytes]]) -> bytes
Parameters
| Name | Type | Description |
|---|---|---|
status |
— |
HTTP status code. |
headers |
— |
Response headers as (name, value) byte pairs. |
Returns
bytes
Serialized HTTP/1.1 response head bytes.
send_body
2
bytes
▼
Serialize a response body chunk into bytes.
send_body
2
bytes
▼
def send_body(self, data: bytes, more: bool = False) -> bytes
Parameters
| Name | Type | Description |
|---|---|---|
data |
— |
Body bytes to send. |
more |
— |
True if more body chunks will follow. Default:False
|
Returns
bytes
Serialized bytes to write to the socket.
start_new_cycle
0
▼
Prepare for the next request on keep-alive connections.
start_new_cycle
0
▼
def start_new_cycle(self) -> None
has_pending_data
0
bool
▼
True if h11 has buffered data from a pipelined request.
After ``start_new_cycl…
has_pending_data
0
bool
▼
def has_pending_data(self) -> bool
True if h11 has buffered data from a pipelined request.
Afterstart_new_cycle(), h11 may still have unconsumed
bytes from a previous read. Check this before doing another
socket read to avoid blocking when data is already available.
Returns
bool
Internal Methods 1 ▼
__init__
1
▼
__init__
1
▼
def __init__(self, *, max_incomplete_event_size: int | None = None) -> None
Parameters
| Name | Type | Description |
|---|---|---|
max_incomplete_event_size |
— |
Default:None
|