{"name":"http-headers","version":"3.0.2","description":"Parse http headers","main":"index.js","scripts":{"test":"standard && tape test.js"},"repository":{"type":"git","url":"git://github.com/watson/http-headers.git"},"dependencies":{"next-line":"^1.1.0"},"devDependencies":{"safe-buffer":"^5.1.1","standard":"^10.0.2","tape":"^4.7.0"},"keywords":["http","https","header","headers","parse","parsing","ServerResponse","response"],"author":{"name":"Thomas Watson Steen","email":"w@tson.dk","url":"https://twitter.com/wa7son"},"license":"MIT","bugs":{"url":"https://github.com/watson/http-headers/issues"},"homepage":"https://github.com/watson/http-headers","coordinates":[55.6757062,12.5774478],"gitHead":"08dcf111f788d8774dfe91516b50364e3e4940da","_id":"http-headers@3.0.2","_npmVersion":"5.5.1","_nodeVersion":"9.2.0","_npmUser":{"name":"watson","email":"w@tson.dk"},"maintainers":[{"name":"watson","email":"w@tson.dk"}],"dist":{"integrity":"sha512-87E1I+2Wg4dxxz4rcxElo3dxO/w1ZtgL1yA0Sb6vH3qU16vRKq1NjWQv9SCY3ly2OQROcoxHZOUpmelS+k6wOw==","shasum":"5147771292f0b39d6778d930a3a59a76fc7ef44d","tarball":"http://registry-npm.ywwl.com/http-headers/download/http-headers-3.0.2.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC+G5tBZkKYCo6Vy/M/Ei8Dpg0o3aqne4sQz0NpTWRcewIgEuGGj8zObK1CKrDRRZHA2GugUvMiWdiDB3ss9yf3F3U="}],"size":4929,"noattachment":false,"key":"/http-headers/-/http-headers-3.0.2.tgz"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/http-headers-3.0.2.tgz_1511101775873_0.15869630430825055"},"directories":{},"readme":"# http-headers\n\n[![Build status](https://travis-ci.org/watson/http-headers.svg?branch=master)](https://travis-ci.org/watson/http-headers)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)\n\nParse the start-line and headers from an HTTP request or reponse.\n\nConverts:\n\n```http\nHTTP/1.1 200 OK\nDate: Tue, 10 Jun 2014 07:19:27 GMT\nConnection: keep-alive\nTransfer-Encoding: chunked\n\nHello World\n```\n\nTo this:\n\n```js\n{\n  version: { major: 1, minor: 1 },\n  statusCode: 200,\n  statusMessage: 'OK',\n  headers: {\n    date: 'Tue, 10 Jun 2014 07:19:27 GMT',\n    connection: 'keep-alive',\n    'transfer-encoding': 'chunked'\n  }\n}\n```\n\n**Features:**\n\n- Auto-detects and ignores body if present\n- Fully [RFC 2068](http://www.rfc-base.org/txt/rfc-2068.txt) compliant\n  (please [open an issue](https://github.com/watson/http-headers/issues)\n  if you find a discrepancy)\n- Support multi-line headers (lines will be joined with a space)\n- Support repeating headers\n\n## Installation\n\n```\nnpm install http-headers --save\n```\n\n## Usage\n\n```js\nvar net = require('net')\nvar httpHeaders = require('http-headers')\n\n// create TCP server\nnet.createServer(function (c) {\n  var buffers = []\n  c.on('data', buffers.push.bind(buffers))\n  c.on('end', function () {\n    var data = Buffer.concat(buffers)\n\n    // parse incoming data as an HTTP request and extra HTTP headers\n    console.log(httpHeaders(data))\n  })\n}).listen(8080)\n```\n\n### `http.ServerReponse` support\n\nIf given an instance of `http.ServerResponse`, the reponse headers is\nautomatically extracted, parsed and returned:\n\n```js\nvar http = require('http')\nvar httpHeaders = require('http-headers')\n\nhttp.createServer(function (req, res) {\n  res.end('Hello World')\n  console.log(httpHeaders(res))\n}).listen(8080)\n```\n\n#### Why?\n\nIf you've ever needed to log or in another way access the headers sent\nto the client on a `http.ServerResponse` in Node.js, you know it's not\nas easy as with the `http.IncomingMessage` headers (which you just\naccess via `request.headers['content-type']`).\n\nResponse headers are not directly available on the `response` object.\nInstead all headers are preprocessed as a string on the private\n`response._header` property and needs to be processed in order to be\navailable as an object.\n\nThis module makes the task super simple.\n\n## API\n\nThe http-headers module exposes a single parser function:\n\n```js\nhttpHeaders(data[, onlyHeaders])\n```\n\nArguments:\n\n- `data` - A string, buffer or instance of `http.ServerReponse`\n- `onlyHeaders` - An optional boolean. If `true`, only the headers\n  object will be returned. Defaults to `false`\n\n### Request example\n\nIf given a request as input:\n\n```http\nGET /foo HTTP/1.1\nDate: Tue, 10 Jun 2014 07:19:27 GMT\nConnection: keep-alive\nTransfer-Encoding: chunked\n\nHello World\n```\n\nReturns:\n\n```js\n{\n  method: 'GET',\n  url: '/foo',\n  version: { major: 1, minor: 1 },\n  headers: {\n    date: 'Tue, 10 Jun 2014 07:19:27 GMT',\n    connection: 'keep-alive',\n    'transfer-encoding': 'chunked'\n  }\n}\n```\n\n### Response example\n\nIf given a request as input:\n\n```http\nHTTP/1.1 200 OK\nDate: Tue, 10 Jun 2014 07:19:27 GMT\nConnection: keep-alive\nTransfer-Encoding: chunked\n\nHello World\n```\n\nReturns:\n\n```js\n{\n  version: { major: 1, minor: 1 },\n  statusCode: 200,\n  statusMessage: 'OK',\n  headers: {\n    date: 'Tue, 10 Jun 2014 07:19:27 GMT',\n    connection: 'keep-alive',\n    'transfer-encoding': 'chunked'\n  }\n}\n```\n\n### `onlyHeaders` example\n\nIf the optional second argument is set to `true`, only headers are\nreturned no matter the type of input:\n\n```js\n{\n  date: 'Tue, 10 Jun 2014 07:19:27 GMT',\n  connection: 'keep-alive',\n  'transfer-encoding': 'chunked'\n}\n```\n\n### No Start-Line\n\nIf the `data` given does not contain an HTTP Start-Line, only the\nheaders are returned, even if the `onlyHeaders` argument is `false`:\n\n```http\nDate: Tue, 10 Jun 2014 07:19:27 GMT\nConnection: keep-alive\nTransfer-Encoding: chunked\n\nHello World\n```\n\nReturns:\n\n```js\n{\n  date: 'Tue, 10 Jun 2014 07:19:27 GMT',\n  connection: 'keep-alive',\n  'transfer-encoding': 'chunked'\n}\n```\n\n## License\n\nMIT\n","publish_time":1511101775984,"_cnpm_publish_time":1511101775984,"dist-tags":{"latest":"3.0.2"}}