# h1

URL: /pounce/api/protocols/h1/
Section: protocols
Description: HTTP/1.1 protocol handler — sans-I/O wrapper around h11.

Translates between raw bytes and typed ProtocolEvents. The worker feeds
bytes in via receive_data() and reads serialized bytes out via send_response()
and send_body().

All state is per-connection, per-request-cycle. No shared mutable state.

---

> For a complete page index, fetch /pounce/llms.txt.

Open LLM text
(/pounce/api/protocols/h1/index.txt)

Share with AI

Ask Claude
(https://claude.ai/new?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpounce%2Fapi%2Fprotocols%2Fh1%2Findex.txt)

Ask ChatGPT
(https://chatgpt.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpounce%2Fapi%2Fprotocols%2Fh1%2Findex.txt)

Ask Gemini
(https://gemini.google.com/app?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpounce%2Fapi%2Fprotocols%2Fh1%2Findex.txt)

Ask Copilot
(https://copilot.microsoft.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpounce%2Fapi%2Fprotocols%2Fh1%2Findex.txt)

Module

#
`protocols.h1`

HTTP/1.1 protocol handler — sans-I/O wrapper around h11.

Translates between raw bytes and typed ProtocolEvents. The worker feeds
bytes in via receive_data() and reads serialized bytes out via send_response()
and send_body().

All state is per-connection, per-request-cycle. No shared mutable state.

1Class

## Classes

`H1Protocol`

12

▼

HTTP/1.1 protocol handler backed by h11.

Implements the ProtocolHandler contract. Each instance ma…

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

`def their_state(self) -> Any`

##### Returns

`Any`

`our_state`

0

`Any`

▼

Current h11 server-side state (for diagnostics).

property

`def our_state(self) -> Any`

##### Returns

`Any`

`client_is_waiting_for_100_continue`

0

`bool`

▼

True if the client sent Expect: 100-continue.

property

`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.

`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.

`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_informational`

2

`bytes`

▼

Serialize a 1xx informational response (e.g. 103 Early Hints).

h11 models inte…

`def send_informational(self, status: int, headers: list[tuple[bytes, bytes]]) -> bytes`

Serialize a 1xx informational response (e.g. 103 Early Hints).

h11 models interim 1xx responses as`InformationalResponse`,
which does not terminate the request-response cycle, so the final
response is still serialized and sent afterwards. Modern browsers
(Chrome 103+, Firefox) honour 103 Early Hints over HTTP/1.1.

##### Parameters

Name
Type
Description

`status`
`—`

1xx HTTP status code.

`headers`
`—`

Response headers as (name, value) byte pairs.

##### Returns

`bytes`

Serialized interim response head bytes.

`send_100_continue`

0

`bytes`

▼

Serialize an interim ``100 Continue`` informational response.

A client that se…

`def send_100_continue(self) -> bytes`

Serialize an interim`100 Continue`informational response.

A client that sends`Expect: 100-continue`withholds the request
body until it observes this interim status line. h11 models it as an
`InformationalResponse`(status 1xx), which does not
terminate the request-response cycle, so the final response is still
sent normally afterwards.

##### Returns

`bytes`

Serialized ``HTTP/1.1 100 Continue`` head bytes.

`send_body`

2

`bytes`

▼

Serialize a response body chunk into 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.

`send_body_parts`

2

`list[bytes | SendfileReg…`

▼

Serialize a response body chunk without combining passthrough data.

h11's ``se…

`def send_body_parts(self, data: bytes | SendfileRegion, more: bool = False) -> list[bytes | SendfileRegion]`

Serialize a response body chunk without combining passthrough data.

h11's`send_with_data_passthrough`preserves the exact object passed
as`Data.data`while still applying Content-Length or chunked writer
accounting. The ASGI bridge uses this for protocol-owned sendfile:
h11 validates the declared body length, and the bridge writes any
framing bytes around the file transfer in order.

##### Parameters

Name
Type
Description

`data`
`—`

`more`
`—`

Default:`False`

##### Returns

`list[bytes | SendfileRegion (/pounce/api/_sendfile/#SendfileRegion)]`

`start_new_cycle`

0

▼

Prepare for the next request on keep-alive connections.

`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…

`def has_pending_data(self) -> bool`

True if h11 has buffered data from a pipelined request.

After`start_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

▼

`def __init__(self, *, max_incomplete_event_size: int | None = None) -> None`

##### Parameters

Name
Type
Description

`max_incomplete_event_size`
`—`

Default:`None`
