# _response_frame

URL: /pounce/api/_response_frame/
Section: api
Description: 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).

---

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

Open LLM text
(/pounce/api/_response_frame/index.txt)

Share with AI

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

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

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

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

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

1Class4Functions

## Classes

`HeaderInjectionError`

0

▼

Raised when a header name or value contains CR/LF characters.

Prevents response-splitting attacks …

Bases:

`ValueError`

Raised when a header name or value contains CR/LF characters.

Prevents response-splitting attacks when callers forward untrusted
data into response headers.

## Functions

`_validate_header_bytes`

2

`None`

▼

Reject CR/LF in header names or values (RFC 9110 §5.5).

`def _validate_header_bytes(name: bytes, value: bytes) -> None`

##### Parameters

Name
Type
Description

`name`
`bytes`

`value`
`bytes`

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