{ "_args": [ [ { "raw": "on-headers@~1.0.0", "scope": null, "escapedName": "on-headers", "name": "on-headers", "rawSpec": "~1.0.0", "spec": ">=1.0.0 <1.1.0", "type": "range" }, "/home/jdaugherty/work/GT2/GT2-Android/node_modules/connect" ] ], "_from": "on-headers@>=1.0.0 <1.1.0", "_id": "on-headers@1.0.1", "_inCache": true, "_location": "/on-headers", "_npmUser": { "name": "dougwilson", "email": "doug@somethingdoug.com" }, "_npmVersion": "1.4.28", "_phantomChildren": {}, "_requested": { "raw": "on-headers@~1.0.0", "scope": null, "escapedName": "on-headers", "name": "on-headers", "rawSpec": "~1.0.0", "spec": ">=1.0.0 <1.1.0", "type": "range" }, "_requiredBy": [ "/compression", "/connect", "/connect-timeout", "/express-session", "/morgan", "/response-time" ], "_resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.1.tgz", "_shasum": "928f5d0f470d49342651ea6794b0857c100693f7", "_shrinkwrap": null, "_spec": "on-headers@~1.0.0", "_where": "/home/jdaugherty/work/GT2/GT2-Android/node_modules/connect", "author": { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" }, "bugs": { "url": "https://github.com/jshttp/on-headers/issues" }, "dependencies": {}, "description": "Execute a listener when a response is about to write headers", "devDependencies": { "istanbul": "0.3.21", "mocha": "2.3.3", "supertest": "1.1.0" }, "directories": {}, "dist": { "shasum": "928f5d0f470d49342651ea6794b0857c100693f7", "tarball": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.1.tgz" }, "engines": { "node": ">= 0.8" }, "files": [ "LICENSE", "HISTORY.md", "README.md", "index.js" ], "gitHead": "ab0156a979d72353cfe666cccb3639e016b00280", "homepage": "https://github.com/jshttp/on-headers#readme", "keywords": [ "event", "headers", "http", "onheaders" ], "license": "MIT", "maintainers": [ { "name": "dougwilson", "email": "doug@somethingdoug.com" }, { "name": "jongleberry", "email": "jonathanrichardong@gmail.com" } ], "name": "on-headers", "optionalDependencies": {}, "readme": "# on-headers\n\n[![NPM Version][npm-image]][npm-url]\n[![NPM Downloads][downloads-image]][downloads-url]\n[![Node.js Version][node-version-image]][node-version-url]\n[![Build Status][travis-image]][travis-url]\n[![Test Coverage][coveralls-image]][coveralls-url]\n\nExecute a listener when a response is about to write headers.\n\n## Installation\n\n```sh\n$ npm install on-headers\n```\n\n## API\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[npm-image]: https://img.shields.io/npm/v/on-headers.svg\n[npm-url]: https://npmjs.org/package/on-headers\n[node-version-image]: https://img.shields.io/node/v/on-headers.svg\n[node-version-url]: http://nodejs.org/download/\n[travis-image]: https://img.shields.io/travis/jshttp/on-headers/master.svg\n[travis-url]: https://travis-ci.org/jshttp/on-headers\n[coveralls-image]: https://img.shields.io/coveralls/jshttp/on-headers/master.svg\n[coveralls-url]: https://coveralls.io/r/jshttp/on-headers?branch=master\n[downloads-image]: https://img.shields.io/npm/dm/on-headers.svg\n[downloads-url]: https://npmjs.org/package/on-headers\n", "readmeFilename": "README.md", "repository": { "type": "git", "url": "git+https://github.com/jshttp/on-headers.git" }, "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/" }, "version": "1.0.1" }