Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

headers

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

headers

  • 0.9.6
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Headers

This is a commonjs compatible Javascript module for parsing and format the following HTTP headers:

  • Content-Type (per RFC 2616)
  • Accept (per RFC 2616)
  • Accept-Language (per RFC 2616)
  • Accept-Charset (per RFC 2616)
  • Accept-Encoding (per RFC 2616)
  • Cookie (per http://tools.ietf.org/html/draft-ietf-httpstate-cookie-18)
  • Set-Cookie (per http://tools.ietf.org/html/draft-ietf-httpstate-cookie-18)
  • Cache-Control (per RFC 2616)
  • Link (per RFC 5988)

Parsing and formatting is implemented by a header module which has two functions parse, and format. Each of these methods accept two arguments - the name of the header, and either a string (for parsing) or an object (for formatting. The structure of the object is specific to each header, but is easily guessable. See the tests directory for examples.

Example

Here is an example to parse a Link header.

var header = require('header');
var str = "<http://foo.com>;rel='http://some.rel.com alternate';title='hello';type='application/xml'";
l = header.parse('Link', val);
console.log(sys.inspect(l));

Formatting follows the same style.

var header = require('header');
sys.log(header.format('Link', {
  href : 'http://www.example.org',
  rel : ['related'],
  title : 'Hello World',
  type : 'text/html'
}));

Installing

npm install headers

FAQs

Package last updated on 08 Oct 2011

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc