structured-headers is a JavaScript/TypeScript library providing a robust parser and serializer for HTTP Structured Field Values (RFC9651 and RFC8941). This specification standardizes complex HTTP header values, including lists, dictionaries, numbers, booleans, binary data (ByteSequences), timestamps, and Unicode strings (Display Strings). The current stable version is 2.0.2. New major versions are typically released to align with updates to the underlying RFCs, such as v2.0.0 which added support for RFC9651's new `Date` and `Display String` types. Patches address bug fixes and dependency updates. Key differentiators include its TypeScript foundation, shipping both ESM and CommonJS builds (though ESM is primary since v2), zero runtime dependencies, and an extensive test suite comprising 2805 unit tests largely sourced from the official HTTP Working Group. The library prioritizes strict RFC compliance, returning data structures that precisely mirror the specification, which can sometimes result in more complex types than developers might initially expect.
npm install structured-headersVerified import paths — ran on the pinned version, not inferred.
Demonstrates parsing various HTTP Structured Field Values: single items with parameters, lists including inner lists, and dictionaries with diverse member types.
Refactor your project to use ES Modules (`import` statements, `"type": "module"` in `package.json` if in Node.js) and ensure your Node.js runtime is version 18 or newer.
Update your code to directly use `ArrayBuffer` instances when dealing with binary structured field values, both for parsing output and serializing input.
Be aware of this limitation in serialization output for numbers where trailing `.0` is significant. No direct workaround is available without custom number wrapping, which the library avoids for developer experience.
Acknowledge this minor discrepancy in floating-point serialization. The library plans to implement a custom rounding algorithm in the future to address this.
Familiarize yourself with the library's specific return types for `parseItem`, `parseList`, and `parseDictionary` to correctly destructure and access the parsed values and their parameters.
Update your import statements to use ES Modules syntax (`import { parseItem } from 'structured-headers';`). If in Node.js, ensure your package.json has `"type": "module"` or your file uses the `.mjs` extension.All binary data input for serialization and output from parsing is now `ArrayBuffer`. Ensure your code converts any `ByteSequence` instances to `ArrayBuffer` before passing them to serializer functions, and updates consumption of parsed binary data to handle `ArrayBuffer`.
No dependency data recorded yet.