A complete RFC 9651 (Structured Field Values for HTTP) parser and serializer. /parse turns a raw field value into typed JSON; /serialize turns typed JSON back into canonical field text. Both are pure computations — no clock, no network, and the only table either route reads is the bundled IANA field-name registry that ?field= resolves against.
Every Section 3 type is implemented: Integer, Decimal, String, Token, Byte Sequence, Boolean, Date and Display String, plus Inner Lists and Parameters at both levels. The specification's bounds are enforced exactly as written: integers are at most fifteen digits, decimals at most twelve integer digits and three fractional digits (rounded half-to-even on serialization, so 0.0015 becomes 0.002 and 0.0025 also becomes 0.002), strings are printable ASCII with backslash escapes, byte sequences are colon-delimited base64, and display strings are %"…" with percent-encoded UTF-8.
?field= reads the IANA registry. Pass a registered field name — ?field=Priority — and the top-level type is taken from the "Structured Type" column of the pinned IANA HTTP Field Name Registry that also powers /api/http-fields, then echoed back in the response and in meta.params. 35 of the 257 registered field names currently carry a Structured Type. A field with an empty column returns 400 rather than a guess, and an unregistered name returns 404.
strict defaults to true, which additionally requires the input to already be in canonical form. Non-canonical but legal input — leading zeros, 1 , 42, a; b=1, unpadded base64 — is rejected with the canonical form in the error message. Set strict=false for plain RFC 9651 parsing, which accepts all of it.
Honest limits
- The JSON shape is ours, not the RFC's. RFC 9651 defines an abstract data model and a wire format, not a JSON encoding.
{"type":"token","value":"bar"} is this API's invention; do not cite it as standard. The wire format on either side of it is the standard.
- Syntax only. Knowing that
Priority is a Dictionary tells you nothing about what u and i mean. Nothing here validates a field's semantics, allowed keys, value ranges or cardinality, and for the one field IANA labels Token the value is parsed as an item without enforcing that the bare item is a token.
- RFC 9651 obsoletes RFC 8941 and adds the Date and Display String types. Fields defined against RFC 8941 may be handled by peers that reject
@1659578233 and %"…", so responses containing those types carry a warning.
- 4096-character inputs. Both
value and json travel in a query string, so they are capped at 4096 characters. RFC 9651 asks parsers to support larger values still (16384-octet byte sequences, 1024-member lists); the parser itself has no limit, but this HTTP transport does.