Package detail

structured-header

evert9MITdeprecated0.1.0

This package has been renamed to structured-headers

Implementation of draft-ietf-httpbis-header-structure, structured headers for HTTP.

http, structured-header

readme

Structured Header parser for Javascript

This library is a parser for the structured header specification. Currently it's still a draft, so this package is also in alpha until the specification stabilizes as a RFC.

Installation

Using npm:

npm install structured-header

Using Yarn:

yarn add structured-header

API

The library exposes 3 functions, and they're used as such:

var header = require('structured-header');

header.parseDictionary('foo=1.23, en="Applepie", da=*w4ZibGV0w6ZydGUK*');
// Returns { foo: 1.23, en: 'Applepie', da: new Buffer('...') };

header.parseList('foo, bar, baz_45');
// Returns ['foo', 'bar', 'baz_45'];

header.parseParameterizedList('abc_123;a=1;b=2; c, def_456, ghi;q="19";r=foo');

// Returns [
//   [ 'abc_123', { a: 1, b: 2, c: null } ],
//   [ 'def_456', {} ],
//   [ 'ghi', { q: '19', r: 'foo' } ]
// ]

Browser support

There is a minified version of this library in the dist/ directory. This minified file will expose a global variable called 'structuredHeader' which contains the rest of the api.

changelog

ChangeLog

0.1.0 (2018-05-07)

  • Automatically running the http-wg test suite.
  • Throwing exceptions on invalid base64 values.
  • Requiring padding in base64 values.

0.0.2 (2018-03-27)

  • Added minified webpacked version.
  • Added readme.
  • Fixed a small bug in identifier parsing.
  • 100% unittest coverage.

0.0.1 (2018-03-26)