node-parse-prefer-header
Parses an HTTP Prefer
header, aka
RFC7240.
const parsePreferHeader = ; const preferences = ;// preferences = { respondAsync: true, wait: '300' }
Installation
$ npm install parse-prefer-header
Features
- Parses the HTTP
Prefer
header into a friendly JavaScript object - Normalizes tokens into JavaScript properties (e.g.
respondAsync
) - Handles quoting correctly (e.g.
foo=";= ,;="
becomes{ foo: ';= ,;='}
) - Supports token parameters
API
parsePreferHeaderpreferHeader: string | string:
Parses the Prefer header value, or an Array of such values, and returns an
object mapping each preference token to its value or true
.
See here for an explanation of the initial set of preferences.