{"library":"parse-headers","title":"HTTP Header Parser","description":"The `parse-headers` package is a lightweight utility designed to transform raw HTTP header strings into a JavaScript object. It is currently at version 2.0.6, with its last update occurring approximately one year ago (as of early 2024), indicating a slow release cadence and minimal active development. The library's core functionality involves parsing a multi-line header string, lowercasing all header names, and consolidating multiple instances of the same header into an array of values. It distinguishes itself by being a zero-dependency solution, making it ideal for environments where a minimal footprint is critical, such as older browser environments via Browserify or for basic XHR header processing. Unlike more comprehensive, RFC-strict parsers that handle structured field values, `parse-headers` offers a straightforward, object-based representation suitable for common, less complex HTTP header scenarios.","language":"javascript","status":"maintenance","last_verified":"Tue Apr 21","install":{"commands":["npm install parse-headers"],"cli":null},"imports":["import parse from 'parse-headers'","const parse = require('parse-headers')","import type { ParsedHeaders } from 'parse-headers'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import parse from 'parse-headers';\n\nconst headersString = [\n  'Date: Sun, 17 Aug 2014 16:24:52 GMT',\n  'Content-Type: text/html; charset=utf-8',\n  'Transfer-Encoding: chunked',\n  'X-Custom-Header: beep',\n  'X-Custom-Header: boop',\n  'Accept-Language: en-US,en;q=0.9,fr;q=0.8'\n].join('\\n');\n\nconst parsed = parse(headersString);\n\nconsole.log(parsed);\n/*\nOutput:\n{\n  date: 'Sun, 17 Aug 2014 16:24:52 GMT',\n  'content-type': 'text/html; charset=utf-8',\n  'transfer-encoding': 'chunked',\n  'x-custom-header': [ 'beep', 'boop' ],\n  'accept-language': 'en-US,en;q=0.9,fr;q=0.8'\n}\n*/\n\n// Accessing a single header\nconsole.log('Content Type:', parsed['content-type']);\n// Accessing a repeated header\nconsole.log('Custom Headers:', parsed['x-custom-header']);","lang":"typescript","description":"Demonstrates parsing a multi-line HTTP header string into a JavaScript object, showing how duplicate headers are handled as arrays.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}