http-sf
Parse and serialise HTTP Structured Fields
What it is and what it does
http-sf is a Python library that implements RFC 9651 for parsing and serializing HTTP Structured Fields. It converts HTTP header values (provided as bytes) into Python data structures—dictionaries, lists, and items—and back again. The library handles the full range of structured field types: integers, decimals, strings, tokens, byte sequences, booleans, dates, and display strings, along with parameters attached to any of these types.
The package provides a functional API via `parse()` and `ser()` functions, with detailed error reporting through `StructuredFieldError` exceptions that include position and context information. It also includes a compatibility layer and a command-line tool for validating and inspecting field values. Requires Python 3.10 or later.
Use it for:
- Parse HTTP Cache-Control, Accept, or other structured headers in web servers or HTTP clients
- Validate and debug HTTP header values from the command line using the built-in CLI
- Migrate existing code from deprecated libraries without rewriting imports via the compat layer
- Build HTTP middleware or proxies that need to inspect and manipulate structured field values
- Implement RFC 9651 compliance in custom HTTP protocol handlers
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses and serializes HTTP Structured Fields as defined by RFC 9651, converting between bytes and Python data structures (dictionaries, lists, items) with support for parameters and multiple field types.
Yes. The package has low install friction, active maintenance, no known vulnerabilities, and a permissive MIT license. It fills a clear need for RFC 9651 compliance in Python HTTP tooling. The functional API is straightforward, error handling is detailed, and a compatibility layer eases migration. Suitable for production use in HTTP-related projects.
Install
http-sf on PyPI
pip
pip install http-sfuv
uv add http-sfpoetry
poetry add http-sfInstalling http-sf
Before you install
Low friction: pure Python wheel with a single runtime dependency (typing_extensions). Actively maintained with recent release activity.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and proprietary projects with minimal obligations.
Quickstart
pip install http-sf
from http_sf import parse, ser
result = parse(b"foo; a=1, bar; b=2", tltype="dictionary")
output = ser(result)
Requires Python 3.10 or later.
Verify before relying
- Whether the library handles all edge cases in RFC 9651 or if certain field types remain unimplemented
- Performance characteristics when parsing very large or deeply nested structured fields
- Compatibility guarantees for the compat layer with all legacy use patterns
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — typing_extensions |
| Maintenance | actively maintained — 81 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 189,741/month — #9,924 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: http_sf-1.3.0-py3-none-any.whl
Tags
More WWW/HTTP packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
h11h11 is a pure-Python HTTP/1.1 protocol…
permissive · top 100 on PyPI
httpxHTTPX is a fully featured HTTP client library…
permissive · top 100 on PyPI
httpcoreA minimal low-level HTTP client library that…
permissive · top 100 on PyPI
aiohttpaiohttp is an async HTTP client and server…
permissive · top 100 on PyPI
http-sfvParses and serializes HTTP Structured Field…
permissive · top 15,000 on PyPI
dicttoxmlConverts Python dictionaries and other native…
copyleft · top 5,000 on PyPI
urlcanonParses and normalizes URLs according to WHATWG…
permissive · top 15,000 on PyPI
pyrfc6266Parses RFC 6266 Content-Disposition headers to…
permissive · top 15,000 on PyPI
python-rapidjsonFast JSON serialization and deserialization…
permissive · top 5,000 on PyPI
pycstructConverts binary data to and from Python…
permissive · top 15,000 on PyPI
mail-parserParses raw email messages into structured…
permissive · top 5,000 on PyPI
jxmleaseConverts XML to Python data structures (lists,…
permissive · top 15,000 on PyPI
cbor2Encodes and decodes CBOR (Concise Binary Object…
permissive · top 1,000 on PyPI