# _headers

URL: /pounce/api/_headers/
Section: api
Description: Shared header lookup utilities.

Single-pass header extraction for ASGI headers (list or tuple of
(name, value) byte pairs). Consolidates the 7 copies of _get_header
scattered across worker, sync_worker, async_pool, and handler modules.

---

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

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

Share with AI

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

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

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

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

Module

#
`_headers`

Shared header lookup utilities.

Single-pass header extraction for ASGI headers (list or tuple of
(name, value) byte pairs). Consolidates the 7 copies of _get_header
scattered across worker, sync_worker, async_pool, and handler modules.

3Functions

## Functions

`is_websocket_upgrade`

1

`bool`

▼

Check if the request is a WebSocket upgrade.

Detects ``Connection: Upgrade`` +…

`def is_websocket_upgrade(request: RequestReceived) -> bool`

Check if the request is a WebSocket upgrade.

Detects`Connection: Upgrade` + `Upgrade: websocket`headers.
Works with both pre-lowered (fast parser) and raw-cased (h11) header names.

##### Parameters

Name
Type
Description

`request`
`RequestReceived (/pounce/api/protocols/_base/#RequestReceived)`

##### Returns

`bool`

`strip_crlf`

1

`str`

▼

Remove CR and LF characters from a header value.

Prevents CRLF injection when …

`def strip_crlf(value: str) -> str`

Remove CR and LF characters from a header value.

Prevents CRLF injection when incorporating external input (e.g. proxy
headers, request IDs) into HTTP headers or ASGI scope fields.

##### Parameters

Name
Type
Description

`value`
`str`

##### Returns

`str`

`get_header`

2

`bytes | None`

▼

Get a header value by lowercase name.

Single linear scan — use when only one h…

`def get_header(headers: Sequence[tuple[bytes, bytes]], name: bytes) -> bytes | None`

Get a header value by lowercase name.

Single linear scan — use when only one header is needed.

##### Parameters

Name
Type
Description

`headers`
`Sequence[tuple[bytes, bytes]]`

ASGI headers (list or tuple of (name, value) pairs).

`name`
`bytes`

Header name to find (compared case-insensitively).

##### Returns

`bytes | None`
