{"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":{"integrity":"sha512-737ZY3yNnXy37FHkQxPzt4UZ2UWPWiCZWLvFZ4fu5cueciegX0zGPnrlY6bwRg4FdQOe9YU8MkmJwGhoMybl8A==","shasum":"59da4f91c45f5f989c6e4bcedc5a3b0aed70ff65","tarball":"http://registry-npm.ywwl.com/on-headers/download/on-headers-1.1.0.tgz","fileCount":5,"unpackedSize":8850,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCUVy2is5P4m0N3XB6teM1voZQw32BHfeSecrmPI3g9nwIhAOy9BKrr9XRi3X2nCi6bTF9emn8xiSsXYR0lCrXKJhMK"}],"size":3607,"noattachment":false,"key":"/on-headers/-/on-headers-1.1.0.tgz"},"_npmUser":{"name":"ulisesgascon","email":"ulisesgascondev@gmail.com"},"directories":{},"maintainers":[{"name":"ulisesgascon","email":"ulisesgascondev@gmail.com"},{"name":"blakeembrey","email":"hello@blakeembrey.com"},{"name":"dougwilson","email":"doug@somethingdoug.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/on-headers_1.1.0_1752766891478_0.8198063790950396"},"_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","publish_time":1752766891684,"_cnpm_publish_time":1752766891684,"dist-tags":{"latest":"1.1.0"}}