Typed, immutable HTTP header fields for Python, parsed and validated against RFC ABNF grammars
Project description
http-fields
Typed, validated HTTP headers for Python. Each header is an immutable dataclass whose fields are the structured components of the header. abnf grammars are used both to parse incoming header strings and to validate field values, so a constructed header is always well-formed.
Requires Python 3.10+.
from http_fields import ContentType, Header
ct = ContentType.parse("text/html; charset=UTF-8")
ct.type, ct.subtype, ct.charset # ('text', 'html', 'UTF-8')
str(ct) # 'Content-Type: text/html;charset=UTF-8'
ContentType.of(type="text", subtype="html", charset="utf-8") # build from pieces
Header.create("x-request-id", "abc123") # dispatch by name
Install
uv add http-fields
# or: pip install http-fields
Documentation
Full documentation: https://http-fields.readthedocs.io/
It follows the Diátaxis model:
- Tutorial: Getting started
- How-to guides: parse & build · custom / unknown headers · Structured Fields
- Reference:
header catalog ·
structuredfieldsAPI - Explanation: the header model
The sources live in docs/.
Development
uv sync # create the environment
uv run pytest # run the tests
uv run ruff check . # lint
uv run ruff format . # format
uv run basedpyright # type-check
uv sync --group docs # add the docs toolchain
uv run sphinx-build -b html docs docs/_build/html # build the docs locally
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file http_fields-0.1.1.tar.gz.
File metadata
- Download URL: http_fields-0.1.1.tar.gz
- Upload date:
- Size: 92.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2cb15e26fea0baa3d04ee242a611f67cd68624eec402cd0a63cf707202245e2
|
|
| MD5 |
4bc20e189ab8938189622a71053c1dca
|
|
| BLAKE2b-256 |
aa1451b932dde5a0b5564a1857ef9f6ce31a9383448d244ba62f0ab99e816ccd
|
Provenance
The following attestation bundles were made for http_fields-0.1.1.tar.gz:
Publisher:
publish.yml on declaresub/http-fields
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
http_fields-0.1.1.tar.gz -
Subject digest:
a2cb15e26fea0baa3d04ee242a611f67cd68624eec402cd0a63cf707202245e2 - Sigstore transparency entry: 2219145527
- Sigstore integration time:
-
Permalink:
declaresub/http-fields@a82a9236d407e0e13e6189d7d1ca1475ea7b149b -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/declaresub
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a82a9236d407e0e13e6189d7d1ca1475ea7b149b -
Trigger Event:
push
-
Statement type:
File details
Details for the file http_fields-0.1.1-py3-none-any.whl.
File metadata
- Download URL: http_fields-0.1.1-py3-none-any.whl
- Upload date:
- Size: 107.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb9c7fb7b760c4e8811e636761decb3d2c82a101a176201c60c4f16f5940daf6
|
|
| MD5 |
15c5d74b6d3b6ecd03789a7710f285da
|
|
| BLAKE2b-256 |
52edd844f6e70e3a80decca048d50c0fa2d282bc29c47a2ea0f7ef83f0984c99
|
Provenance
The following attestation bundles were made for http_fields-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on declaresub/http-fields
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
http_fields-0.1.1-py3-none-any.whl -
Subject digest:
bb9c7fb7b760c4e8811e636761decb3d2c82a101a176201c60c4f16f5940daf6 - Sigstore transparency entry: 2219145558
- Sigstore integration time:
-
Permalink:
declaresub/http-fields@a82a9236d407e0e13e6189d7d1ca1475ea7b149b -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/declaresub
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a82a9236d407e0e13e6189d7d1ca1475ea7b149b -
Trigger Event:
push
-
Statement type: