{"library":"parse-http-header","title":"HTTP Header Value Parameter Parser","description":"The `parse-http-header` package (version 1.0.1) is a lightweight JavaScript utility specifically designed to extract structured information from parameterized HTTP header *value strings*. For instance, a common header value like `text/html; charset=UTF-8` is parsed into an object where `text/html` is accessible as the first element of an array, and parameters like `charset` are exposed as direct properties of that object. This allows developers to easily access both the primary media type and its associated attributes in a unified structure. Originally published around 2014, the library appears to be stable but has not seen active development or new releases in many years. Its key differentiators include its focused scope on parsing *just* the value string portion of a header, rather than handling full HTTP messages or multiple header lines, and its minimal footprint with no external runtime dependencies. It exclusively uses CommonJS module syntax.","language":"javascript","status":"abandoned","last_verified":"Wed Apr 22","install":{"commands":["npm install parse-http-header"],"cli":null},"imports":["const parseHttpHeader = require('parse-http-header');","const headerValue = parseHttpHeader('text/html; charset=UTF-8');\nconst mainType = headerValue[0]; // 'text/html'\nconst charset = headerValue.charset; // 'UTF-8'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const parseHttpHeader = require('parse-http-header');\n\n// Simulate a response headers object\nconst responseHeaders = {\n  'content-type': 'text/html; charset=UTF-8',\n  'content-disposition': 'attachment; filename=\"report.pdf\"; size=12345'\n};\n\n// Parse Content-Type\nconst contentType = parseHttpHeader(responseHeaders['content-type']);\nconsole.log('Content-Type main value:', contentType[0]); // Output: text/html\nconsole.log('Content-Type charset:', contentType.charset); // Output: UTF-8\n\n// Parse Content-Disposition\nconst contentDisposition = parseHttpHeader(responseHeaders['content-disposition']);\nconsole.log('Content-Disposition main value:', contentDisposition[0]); // Output: attachment\nconsole.log('Content-Disposition filename:', contentDisposition.filename); // Output: report.pdf\nconsole.log('Content-Disposition size:', contentDisposition.size); // Output: 12345","lang":"javascript","description":"Demonstrates how to parse common parameterized HTTP header value strings like Content-Type and Content-Disposition, showing access to both the primary value and its parameters.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}