Module

_response_frame

Pre-built HTTP response framing for the fused sync path.

Bypasses H1Protocol/h11 for the hot path — serializes response directly to avoid protocol state machine overhead. Date header cached per-second (RFC 7231 allows 1s resolution).

Functions

serialize_raw_response 5 bytes
Serialize a full HTTP/1.1 response without using h11.
def serialize_raw_response(status: int, headers: tuple[tuple[bytes, bytes], ...], body: bytes, *, server_header: str = 'pounce', date_header: bytes | None = None) -> bytes
Parameters
Name Type Description
status int

HTTP status code.

headers tuple[tuple[bytes, bytes], ...]

Response headers as (name, value) byte pairs.

body bytes

Response body bytes.

server_header str

Value for Server header.

Default:'pounce'
date_header bytes | None

Pre-formatted Date header (e.g. b"date: Wed, 11 Mar 2025 12:00:00 GMT\r\n"). If None, omitted (client may cache less effectively).

Default:None
Returns
bytes
serialize_raw_response_parts 5 tuple[bytes, bytes]
Serialize HTTP/1.1 response as (head, body) for scatter-gather send. Use with …
def serialize_raw_response_parts(status: int, headers: tuple[tuple[bytes, bytes], ...], body: bytes, *, server_header: str = 'pounce', date_header: bytes | None = None) -> tuple[bytes, bytes]

Serialize HTTP/1.1 response as (head, body) for scatter-gather send.

Use with socket.sendmsg([head, body]) to avoid concatenation.

Parameters
Name Type Description
status int
headers tuple[tuple[bytes, bytes], ...]
body bytes
server_header str Default:'pounce'
date_header bytes | None Default:None
Returns
tuple[bytes, bytes]
get_date_header_bytes 0 bytes
RFC 7231 Date header value, e.g. b'date: Wed, 11 Mar 2025 12:00:00 GMT\r\n'.
def get_date_header_bytes() -> bytes
Returns
bytes