Skip to main content

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:

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

http_fields-0.1.1.tar.gz (92.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

http_fields-0.1.1-py3-none-any.whl (107.2 kB view details)

Uploaded Python 3

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

Hashes for http_fields-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a2cb15e26fea0baa3d04ee242a611f67cd68624eec402cd0a63cf707202245e2
MD5 4bc20e189ab8938189622a71053c1dca
BLAKE2b-256 aa1451b932dde5a0b5564a1857ef9f6ce31a9383448d244ba62f0ab99e816ccd

See more details on using hashes here.

Provenance

The following attestation bundles were made for http_fields-0.1.1.tar.gz:

Publisher: publish.yml on declaresub/http-fields

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for http_fields-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bb9c7fb7b760c4e8811e636761decb3d2c82a101a176201c60c4f16f5940daf6
MD5 15c5d74b6d3b6ecd03789a7710f285da
BLAKE2b-256 52edd844f6e70e3a80decca048d50c0fa2d282bc29c47a2ea0f7ef83f0984c99

See more details on using hashes here.

Provenance

The following attestation bundles were made for http_fields-0.1.1-py3-none-any.whl:

Publisher: publish.yml on declaresub/http-fields

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page