{"_id":"http-headers","_rev":"2934727","name":"http-headers","description":"Parse http headers","dist-tags":{"latest":"3.0.2"},"maintainers":[{"name":"watson","email":""}],"time":{"modified":"2023-03-29T06:05:26.000Z","created":"2014-06-10T07:49:24.558Z","3.0.2":"2017-11-19T14:29:35.984Z","3.0.1":"2016-04-26T07:20:43.492Z","3.0.0":"2016-04-25T22:58:17.281Z","2.0.0":"2016-04-25T22:41:16.901Z","1.2.0":"2015-09-24T00:40:14.119Z","1.1.1":"2015-08-31T14:43:25.285Z","1.1.0":"2015-08-31T12:28:13.289Z","1.0.0":"2015-08-30T22:40:15.594Z","0.1.0":"2014-06-10T07:49:24.558Z"},"users":{},"author":{"name":"Thomas Watson Steen","email":"w@tson.dk","url":"https://twitter.com/wa7son"},"repository":{"type":"git","url":"git://github.com/watson/http-headers.git"},"versions":{"3.0.2":{"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":""}],"dist":{"shasum":"5147771292f0b39d6778d930a3a59a76fc7ef44d","size":4929,"noattachment":false,"key":"/http-headers/-/http-headers-3.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/http-headers/download/http-headers-3.0.2.tgz"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/http-headers-3.0.2.tgz_1511101775873_0.15869630430825055"},"directories":{},"publish_time":1511101775984,"_hasShrinkwrap":false,"_cnpm_publish_time":1511101775984,"_cnpmcore_publish_time":"2021-12-16T14:20:35.724Z"},"3.0.1":{"name":"http-headers","version":"3.0.1","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.0.0"},"devDependencies":{"standard":"^5.1.1","tape":"^4.2.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.687709,12.5955128],"gitHead":"04621dcc39ea153238f498d8bac59531b34f3e96","_id":"http-headers@3.0.1","_shasum":"1cbc691c45cdf6d6c1dc63bf368b2505f56ef839","_from":".","_npmVersion":"2.14.7","_nodeVersion":"4.2.2","_npmUser":{"name":"watson","email":"w@tson.dk"},"maintainers":[{"name":"watson","email":""}],"dist":{"shasum":"1cbc691c45cdf6d6c1dc63bf368b2505f56ef839","size":4872,"noattachment":false,"key":"/http-headers/-/http-headers-3.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/http-headers/download/http-headers-3.0.1.tgz"},"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/http-headers-3.0.1.tgz_1461655241531_0.09670431981794536"},"directories":{},"publish_time":1461655243492,"_hasShrinkwrap":false,"_cnpm_publish_time":1461655243492,"_cnpmcore_publish_time":"2021-12-16T14:20:35.936Z"},"3.0.0":{"name":"http-headers","version":"3.0.0","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.0.0"},"devDependencies":{"standard":"^5.1.1","tape":"^4.2.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.6876742,12.5955475],"gitHead":"c6aaf182b44c07d7fc4e2f57e873df4d0b28e869","_id":"http-headers@3.0.0","_shasum":"451d512e0e64fc043271ed2fb0f0b981a7e9ed04","_from":".","_npmVersion":"2.14.7","_nodeVersion":"4.2.2","_npmUser":{"name":"watson","email":"w@tson.dk"},"maintainers":[{"name":"watson","email":""}],"dist":{"shasum":"451d512e0e64fc043271ed2fb0f0b981a7e9ed04","size":4879,"noattachment":false,"key":"/http-headers/-/http-headers-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/http-headers/download/http-headers-3.0.0.tgz"},"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/http-headers-3.0.0.tgz_1461625095357_0.4028472318314016"},"directories":{},"publish_time":1461625097281,"_hasShrinkwrap":false,"_cnpm_publish_time":1461625097281,"_cnpmcore_publish_time":"2021-12-16T14:20:36.240Z"},"2.0.0":{"name":"http-headers","version":"2.0.0","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.0.0"},"devDependencies":{"standard":"^5.1.1","tape":"^4.2.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.6876679,12.5955582],"gitHead":"6a29fc6f8016a7f5ee6d16109fcae00e292617ae","_id":"http-headers@2.0.0","_shasum":"de50ebf7a3abcdc313d3d05597c380a39dd5340c","_from":".","_npmVersion":"2.14.7","_nodeVersion":"4.2.2","_npmUser":{"name":"watson","email":"w@tson.dk"},"maintainers":[{"name":"watson","email":""}],"dist":{"shasum":"de50ebf7a3abcdc313d3d05597c380a39dd5340c","size":4865,"noattachment":false,"key":"/http-headers/-/http-headers-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/http-headers/download/http-headers-2.0.0.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/http-headers-2.0.0.tgz_1461624074441_0.907281719148159"},"directories":{},"publish_time":1461624076901,"_hasShrinkwrap":false,"_cnpm_publish_time":1461624076901,"_cnpmcore_publish_time":"2021-12-16T14:20:36.480Z"},"1.2.0":{"name":"http-headers","version":"1.2.0","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.0.0","strip-lines":"^1.0.1"},"devDependencies":{"standard":"^5.1.1","tape":"^4.2.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.68773059999999,12.5956059],"gitHead":"8592404b6611650cc2dcb603cc2ec6fc4d928b5a","_id":"http-headers@1.2.0","_shasum":"0c754239fc14aec858bda1cbd069f171bfa6a3fa","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"watson","email":"w@tson.dk"},"maintainers":[{"name":"watson","email":""}],"dist":{"shasum":"0c754239fc14aec858bda1cbd069f171bfa6a3fa","size":3886,"noattachment":false,"key":"/http-headers/-/http-headers-1.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/http-headers/download/http-headers-1.2.0.tgz"},"directories":{},"publish_time":1443055214119,"_hasShrinkwrap":false,"_cnpm_publish_time":1443055214119,"_cnpmcore_publish_time":"2021-12-16T14:20:36.689Z"},"1.1.1":{"name":"http-headers","version":"1.1.1","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.0.0","strip-lines":"^1.0.1"},"devDependencies":{"standard":"^5.1.1","tape":"^4.2.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.6876735,12.5956032],"gitHead":"b62d7a1eadba112e83966affe38bc4997941de69","_id":"http-headers@1.1.1","_shasum":"77f5a4eef5c8f9ca4ec6098a497235c4b114bf6f","_from":".","_npmVersion":"2.13.4","_nodeVersion":"0.12.7","_npmUser":{"name":"watson","email":"w@tson.dk"},"maintainers":[{"name":"watson","email":""}],"dist":{"shasum":"77f5a4eef5c8f9ca4ec6098a497235c4b114bf6f","size":3888,"noattachment":false,"key":"/http-headers/-/http-headers-1.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/http-headers/download/http-headers-1.1.1.tgz"},"directories":{},"publish_time":1441032205285,"_hasShrinkwrap":false,"_cnpm_publish_time":1441032205285,"_cnpmcore_publish_time":"2021-12-16T14:20:37.173Z"},"1.1.0":{"name":"http-headers","version":"1.1.0","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.0.0","strip-lines":"^1.0.0"},"devDependencies":{"standard":"^5.1.1","tape":"^4.2.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.677415,12.5819575],"gitHead":"9680e0aa74a72e7fdadb41ac6cb66360d0078615","_id":"http-headers@1.1.0","_shasum":"74798a36276ab6c47c385e0d743a8fd5c82d917a","_from":".","_npmVersion":"2.13.4","_nodeVersion":"0.12.7","_npmUser":{"name":"watson","email":"w@tson.dk"},"maintainers":[{"name":"watson","email":""}],"dist":{"shasum":"74798a36276ab6c47c385e0d743a8fd5c82d917a","size":3856,"noattachment":false,"key":"/http-headers/-/http-headers-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/http-headers/download/http-headers-1.1.0.tgz"},"directories":{},"publish_time":1441024093289,"_hasShrinkwrap":false,"_cnpm_publish_time":1441024093289,"_cnpmcore_publish_time":"2021-12-16T14:20:37.377Z"},"1.0.0":{"name":"http-headers","version":"1.0.0","description":"Parse http headers","main":"index.js","scripts":{"test":"standard && tape test.js"},"repository":{"type":"git","url":"git://github.com/watson/http-headers.git"},"devDependencies":{"standard":"^5.1.1","tape":"^4.2.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.687573956701705,12.595934558563272],"gitHead":"6621a341d63ff9f88b6cee5457cef52df67025dd","_id":"http-headers@1.0.0","_shasum":"ffe41d27451e8c6859b89100c6763820bc4d7b26","_from":".","_npmVersion":"2.13.4","_nodeVersion":"0.12.7","_npmUser":{"name":"watson","email":"w@tson.dk"},"maintainers":[{"name":"watson","email":""}],"dist":{"shasum":"ffe41d27451e8c6859b89100c6763820bc4d7b26","size":3540,"noattachment":false,"key":"/http-headers/-/http-headers-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/http-headers/download/http-headers-1.0.0.tgz"},"directories":{},"publish_time":1440974415594,"_hasShrinkwrap":false,"_cnpm_publish_time":1440974415594,"_cnpmcore_publish_time":"2021-12-16T14:20:37.592Z"},"0.1.0":{"name":"http-headers","version":"0.1.0","description":"Parse http headers","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git://github.com/watson/http-headers.git"},"keywords":["http","https","header","headers","parse","parsing","ServerResponse","response"],"author":{"name":"Thomas Watson Steen","email":"w@tson.dk"},"license":"MIT","bugs":{"url":"https://github.com/watson/http-headers/issues"},"homepage":"https://github.com/watson/http-headers","_id":"http-headers@0.1.0","_shasum":"e0597cc7c2d6e8ce0d33a325807b882eed86a9b1","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"watson","email":"w@tson.dk"},"maintainers":[{"name":"watson","email":""}],"dist":{"shasum":"e0597cc7c2d6e8ce0d33a325807b882eed86a9b1","size":2734,"noattachment":false,"key":"/http-headers/-/http-headers-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/http-headers/download/http-headers-0.1.0.tgz"},"directories":{},"publish_time":1402386564558,"_hasShrinkwrap":false,"_cnpm_publish_time":1402386564558,"_cnpmcore_publish_time":"2021-12-16T14:20:37.821Z"}},"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","_attachments":{},"homepage":"https://github.com/watson/http-headers","bugs":{"url":"https://github.com/watson/http-headers/issues"},"license":"MIT"}