1.0.0 • Published 9 years ago

header-parser v1.0.0

Weekly downloads
18
License
MIT
Repository
github
Last release
9 years ago

Header Parser Middleware

Some headers can be query-string encoded so this middleware makes 2 methods available to access parsed versions of those headers.

Usage

> npm install header-parser
var headerParser = require('header-parser');
var app = express();

app.use(headerParser);

req.getParsed(field)

Returns the specified HTTP request header field (case-insensitive match) that is encoded in query-string format as JSON.

req.get('X-Custom-Header');
// => "foo=bar&baz=My%20Val"

req.getParsed('X-Custom-Header');
/* =>
{
	foo: 'bar',
	baz: 'My Val'
}
*/

Aliased for req.headerParsed(field).