Socket
Socket
Sign inDemoInstall

http-headers

Package Overview
Dependencies
0
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    http-headers

Parse http headers


Version published
Maintainers
1
Install size
5.58 kB
Created

Readme

Source

http-headers

Build Status

HTTP header string parser.

Converts:

HTTP/1.1 200 OK
Date: Tue, 10 Jun 2014 07:19:27 GMT
Connection: keep-alive
Transfer-Encoding: chunked

To this:

{ date: 'Tue, 10 Jun 2014 07:19:27 GMT',
  connection: 'keep-alive',
  'transfer-encoding': 'chunked' }

Why?

If you've ever needed to log or in another way access the headers sent to the client on a http.ServerResponse in Node.js, you know it's not as easy as with the http.IncomingMessage headers (which you just access via request.headers['content-type']).

Response headers are not directly available on the response object. Instead all headers are preprocessed as a string on the private response._header property and needs to be processed in order to be available as an object.

This module makes the task super simple.

Installation

npm install http-headers

Usage

var httpHeaders = require('http-headers');

http.createServer(function (req, res) {
  res.end('Hello World');
  console.log('The headers sent to the client was:', httpHeaders(res));
});

License

MIT

Keywords

FAQs

Last updated on 10 Jun 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc