{"_id":"on-headers","_rev":"3945747","name":"on-headers","description":"Execute a listener when a response is about to write headers","dist-tags":{"latest":"1.1.0"},"maintainers":[{"name":"blakeembrey","email":"hello@blakeembrey.com"},{"name":"dougwilson","email":""},{"name":"ulisesgascon","email":""}],"time":{"modified":"2025-09-01T01:33:55.000Z","created":"2014-05-14T01:43:08.147Z","1.1.0":"2025-07-17T15:41:31.684Z","1.0.2":"2019-02-22T03:48:54.600Z","1.0.1":"2015-09-30T03:47:06.558Z","1.0.0":"2014-08-10T23:14:54.117Z","0.0.0":"2014-05-14T01:43:08.147Z"},"users":{"tarunbk":true,"henrytseng":true,"carlosvillademor":true,"mojaray2k":true,"jimjin":true,"rocket0191":true,"shanewholloway":true},"author":{"name":"Douglas Christopher Wilson","email":"doug@somethingdoug.com"},"repository":{"type":"git","url":"git+https://github.com/jshttp/on-headers.git"},"versions":{"1.1.0":{"name":"on-headers","description":"Execute a listener when a response is about to write headers","version":"1.1.0","author":{"name":"Douglas Christopher Wilson","email":"doug@somethingdoug.com"},"license":"MIT","keywords":["event","headers","http","onheaders"],"repository":{"type":"git","url":"git+https://github.com/jshttp/on-headers.git"},"devDependencies":{"eslint":"6.8.0","eslint-config-standard":"14.1.1","eslint-plugin-import":"2.21.2","eslint-plugin-markdown":"1.0.2","eslint-plugin-node":"11.1.0","eslint-plugin-promise":"4.2.1","eslint-plugin-standard":"4.0.1","mocha":"10.2.0","nyc":"15.1.0","supertest":"4.0.2"},"engines":{"node":">= 0.8"},"scripts":{"lint":"eslint --plugin markdown --ext js,md .","test":"mocha --reporter spec --check-leaks test/test.js","test-ci":"nyc --reporter=lcov --reporter=text npm test","test-cov":"nyc --reporter=html --reporter=text npm test","update-upstream-hashes":"node scripts/update-upstream-hashes.js","upstream":"mocha --reporter spec --check-leaks test/upstream.js","version":"node scripts/version-history.js && git add HISTORY.md"},"_id":"on-headers@1.1.0","gitHead":"4b017af88f5375bbdf3ad2ee732d2c122e4f52b0","bugs":{"url":"https://github.com/jshttp/on-headers/issues"},"homepage":"https://github.com/jshttp/on-headers#readme","_nodeVersion":"22.10.0","_npmVersion":"10.9.0","dist":{"shasum":"59da4f91c45f5f989c6e4bcedc5a3b0aed70ff65","size":3607,"noattachment":false,"key":"/on-headers/-/on-headers-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/on-headers/download/on-headers-1.1.0.tgz"},"_npmUser":{"name":"ulisesgascon","email":"ulisesgascondev@gmail.com"},"directories":{},"maintainers":[{"name":"blakeembrey","email":"hello@blakeembrey.com"},{"name":"dougwilson","email":""},{"name":"ulisesgascon","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/on-headers_1.1.0_1752766891478_0.8198063790950396"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-07-17T15:41:31.684Z","publish_time":1752766891684,"_source_registry_name":"default","_cnpm_publish_time":1752766891684},"1.0.2":{"name":"on-headers","description":"Execute a listener when a response is about to write headers","version":"1.0.2","author":{"name":"Douglas Christopher Wilson","email":"doug@somethingdoug.com"},"license":"MIT","keywords":["event","headers","http","onheaders"],"repository":{"type":"git","url":"git+https://github.com/jshttp/on-headers.git"},"devDependencies":{"eslint":"5.14.1","eslint-config-standard":"12.0.0","eslint-plugin-import":"2.16.0","eslint-plugin-markdown":"1.0.0","eslint-plugin-node":"8.0.1","eslint-plugin-promise":"4.0.1","eslint-plugin-standard":"4.0.0","istanbul":"0.4.5","mocha":"6.0.1","supertest":"3.4.2"},"engines":{"node":">= 0.8"},"scripts":{"lint":"eslint --plugin markdown --ext js,md .","test":"mocha --reporter spec --bail --check-leaks test/","test-cov":"istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/","test-travis":"istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/","version":"node scripts/version-history.js && git add HISTORY.md"},"gitHead":"c05140cde9bbce2127926752433271c6f3fe8787","bugs":{"url":"https://github.com/jshttp/on-headers/issues"},"homepage":"https://github.com/jshttp/on-headers#readme","_id":"on-headers@1.0.2","_npmVersion":"6.4.1","_nodeVersion":"8.15.0","_npmUser":{"name":"dougwilson","email":"doug@somethingdoug.com"},"dist":{"shasum":"772b0ae6aaa525c399e489adfad90c403eb3c28f","size":3225,"noattachment":false,"key":"/on-headers/-/on-headers-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/on-headers/download/on-headers-1.0.2.tgz"},"maintainers":[{"name":"blakeembrey","email":"hello@blakeembrey.com"},{"name":"dougwilson","email":""},{"name":"ulisesgascon","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/on-headers_1.0.2_1550807334461_0.2296705941712791"},"_hasShrinkwrap":false,"publish_time":1550807334600,"_cnpm_publish_time":1550807334600},"1.0.1":{"name":"on-headers","description":"Execute a listener when a response is about to write headers","version":"1.0.1","author":{"name":"Douglas Christopher Wilson","email":"doug@somethingdoug.com"},"license":"MIT","keywords":["event","headers","http","onheaders"],"repository":{"type":"git","url":"https://github.com/jshttp/on-headers"},"dependencies":{},"devDependencies":{"istanbul":"0.3.21","mocha":"2.3.3","supertest":"1.1.0"},"files":["LICENSE","HISTORY.md","README.md","index.js"],"engines":{"node":">= 0.8"},"scripts":{"test":"mocha --reporter spec --bail --check-leaks test/","test-cov":"istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/","test-travis":"istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"},"gitHead":"ab0156a979d72353cfe666cccb3639e016b00280","bugs":{"url":"https://github.com/jshttp/on-headers/issues"},"homepage":"https://github.com/jshttp/on-headers","_id":"on-headers@1.0.1","_shasum":"928f5d0f470d49342651ea6794b0857c100693f7","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"dougwilson","email":"doug@somethingdoug.com"},"maintainers":[{"name":"blakeembrey","email":"hello@blakeembrey.com"},{"name":"dougwilson","email":""},{"name":"ulisesgascon","email":""}],"dist":{"shasum":"928f5d0f470d49342651ea6794b0857c100693f7","size":2873,"noattachment":false,"key":"/on-headers/-/on-headers-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/on-headers/download/on-headers-1.0.1.tgz"},"directories":{},"publish_time":1443584826558,"_cnpm_publish_time":1443584826558,"_hasShrinkwrap":false},"1.0.0":{"name":"on-headers","description":"Execute a listener when a response is about to write headers","version":"1.0.0","author":{"name":"Douglas Christopher Wilson","email":"doug@somethingdoug.com"},"license":"MIT","keywords":["event","headers","http","onheaders"],"repository":{"type":"git","url":"https://github.com/jshttp/on-headers"},"dependencies":{},"devDependencies":{"istanbul":"0.3.0","mocha":"~1.21.4","supertest":"~0.13.0"},"engines":{"node":">= 0.8.0"},"scripts":{"test":"mocha --reporter spec --bail --check-leaks test/","test-cov":"istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/","test-travis":"istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"},"gitHead":"434950a0748cd38bf9a04f3fd4f3ff89cf565fda","bugs":{"url":"https://github.com/jshttp/on-headers/issues"},"homepage":"https://github.com/jshttp/on-headers","_id":"on-headers@1.0.0","_shasum":"2c75b5da4375513d0161c6052e7fcbe4953fca5d","_from":".","_npmVersion":"1.4.21","_npmUser":{"name":"dougwilson","email":"doug@somethingdoug.com"},"maintainers":[{"name":"blakeembrey","email":"hello@blakeembrey.com"},{"name":"dougwilson","email":""},{"name":"ulisesgascon","email":""}],"dist":{"shasum":"2c75b5da4375513d0161c6052e7fcbe4953fca5d","size":2776,"noattachment":false,"key":"/on-headers/-/on-headers-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/on-headers/download/on-headers-1.0.0.tgz"},"directories":{},"publish_time":1407712494117,"_cnpm_publish_time":1407712494117,"_hasShrinkwrap":false},"0.0.0":{"name":"on-headers","description":"Execute a listener when a response is about to write headers","version":"0.0.0","author":{"name":"Douglas Christopher Wilson","email":"doug@somethingdoug.com"},"license":"MIT","keywords":["event","headers","http","onheaders"],"repository":{"type":"git","url":"https://github.com/expressjs/on-headers.git"},"bugs":{"url":"https://github.com/expressjs/on-headers/issues"},"dependencies":{},"devDependencies":{"mocha":"~1.18.2","supertest":"~0.12.1"},"engines":{"node":">= 0.8.0"},"scripts":{"test":"mocha --reporter spec test/"},"homepage":"https://github.com/expressjs/on-headers","_id":"on-headers@0.0.0","dist":{"shasum":"ee2817f8344325785cd9c2df2b242bbc17caf4c4","size":2399,"noattachment":false,"key":"/on-headers/-/on-headers-0.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/on-headers/download/on-headers-0.0.0.tgz"},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"dougwilson","email":"doug@somethingdoug.com"},"maintainers":[{"name":"blakeembrey","email":"hello@blakeembrey.com"},{"name":"dougwilson","email":""},{"name":"ulisesgascon","email":""}],"directories":{},"publish_time":1400031788147,"_cnpm_publish_time":1400031788147,"_hasShrinkwrap":false}},"readme":"# on-headers\n\n[![NPM Version][npm-version-image]][npm-url]\n[![NPM Downloads][npm-downloads-image]][npm-url]\n[![Node.js Version][node-image]][node-url]\n[![Build Status][ci-image]][ci-url]\n[![Coverage Status][coveralls-image]][coveralls-url]\n\nExecute a listener when a response is about to write headers.\n\n## Installation\n\nThis is a [Node.js](https://nodejs.org/en/) module available through the\n[npm registry](https://www.npmjs.com/). Installation is done using the\n[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):\n\n```sh\n$ npm install on-headers\n```\n\n## API\n\n<!-- eslint-disable no-unused-vars -->\n\n```js\nvar onHeaders = require('on-headers')\n```\n\n### onHeaders(res, listener)\n\nThis will add the listener `listener` to fire when headers are emitted for `res`.\nThe listener is passed the `response` object as it's context (`this`). Headers are\nconsidered to be emitted only once, right before they are sent to the client.\n\nWhen this is called multiple times on the same `res`, the `listener`s are fired\nin the reverse order they were added.\n\n## Examples\n\n```js\nvar http = require('http')\nvar onHeaders = require('on-headers')\n\nhttp\n  .createServer(onRequest)\n  .listen(3000)\n\nfunction addPoweredBy () {\n  // set if not set by end of request\n  if (!this.getHeader('X-Powered-By')) {\n    this.setHeader('X-Powered-By', 'Node.js')\n  }\n}\n\nfunction onRequest (req, res) {\n  onHeaders(res, addPoweredBy)\n\n  res.setHeader('Content-Type', 'text/plain')\n  res.end('hello!')\n}\n```\n\n## Testing\n\n```sh\n$ npm test\n```\n\n## License\n\n[MIT](LICENSE)\n\n[ci-image]: https://badgen.net/github/checks/jshttp/on-headers/master?label=ci\n[ci-url]: https://github.com/jshttp/on-headers/actions/workflows/ci.yml\n[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/on-headers/master\n[coveralls-url]: https://coveralls.io/r/jshttp/on-headers?branch=master\n[node-image]: https://badgen.net/npm/node/on-headers\n[node-url]: https://nodejs.org/en/download\n[npm-downloads-image]: https://badgen.net/npm/dm/on-headers\n[npm-url]: https://npmjs.org/package/on-headers\n[npm-version-image]: https://badgen.net/npm/v/on-headers\n","_attachments":{},"homepage":"https://github.com/jshttp/on-headers#readme","bugs":{"url":"https://github.com/jshttp/on-headers/issues"},"license":"MIT"}