@toolsnap/http-header-checker
v1.0.0
Published
HTTP header parsing and manipulation utility
Downloads
76
Maintainers
Readme
@toolsnap/http-header-checker
HTTP header parsing and manipulation utility. Zero dependencies, pure JavaScript.
Install
npm install @toolsnap/http-header-checkerUsage
const { parseHeaders, getHeader, setHeader, parseContentType } = require('@toolsnap/http-header-checker');
const headers = parseHeaders('Content-Type: text/html; charset=utf-8\nX-Custom: value');
getHeader(headers, 'content-type'); // 'text/html; charset=utf-8'
parseContentType('text/html; charset=utf-8');
// { type: 'text/html', charset: 'utf-8', boundary: '' }API
parseHeaders(headerStr)— Parse raw HTTP header string into objectgetHeader(headers, name)— Get a header value (case-insensitive)setHeader(headers, name, value)— Set a header valueparseContentType(ct)— Parse Content-Type into type, charset, boundary
License
MIT © Rocky Luo
