109 lines
7.7 KiB
JSON
109 lines
7.7 KiB
JSON
{
|
|
"_args": [
|
|
[
|
|
{
|
|
"raw": "on-finished@~2.3.0",
|
|
"scope": null,
|
|
"escapedName": "on-finished",
|
|
"name": "on-finished",
|
|
"rawSpec": "~2.3.0",
|
|
"spec": ">=2.3.0 <2.4.0",
|
|
"type": "range"
|
|
},
|
|
"/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/body-parser"
|
|
]
|
|
],
|
|
"_from": "on-finished@>=2.3.0 <2.4.0",
|
|
"_id": "on-finished@2.3.0",
|
|
"_inCache": true,
|
|
"_location": "/on-finished",
|
|
"_npmUser": {
|
|
"name": "dougwilson",
|
|
"email": "doug@somethingdoug.com"
|
|
},
|
|
"_npmVersion": "1.4.28",
|
|
"_phantomChildren": {},
|
|
"_requested": {
|
|
"raw": "on-finished@~2.3.0",
|
|
"scope": null,
|
|
"escapedName": "on-finished",
|
|
"name": "on-finished",
|
|
"rawSpec": "~2.3.0",
|
|
"spec": ">=2.3.0 <2.4.0",
|
|
"type": "range"
|
|
},
|
|
"_requiredBy": [
|
|
"/body-parser",
|
|
"/express",
|
|
"/finalhandler",
|
|
"/send"
|
|
],
|
|
"_resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz",
|
|
"_shasum": "20f1336481b083cd75337992a16971aa2d906947",
|
|
"_shrinkwrap": null,
|
|
"_spec": "on-finished@~2.3.0",
|
|
"_where": "/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/body-parser",
|
|
"bugs": {
|
|
"url": "https://github.com/jshttp/on-finished/issues"
|
|
},
|
|
"contributors": [
|
|
{
|
|
"name": "Douglas Christopher Wilson",
|
|
"email": "doug@somethingdoug.com"
|
|
},
|
|
{
|
|
"name": "Jonathan Ong",
|
|
"email": "me@jongleberry.com",
|
|
"url": "http://jongleberry.com"
|
|
}
|
|
],
|
|
"dependencies": {
|
|
"ee-first": "1.1.1"
|
|
},
|
|
"description": "Execute a callback when a request closes, finishes, or errors",
|
|
"devDependencies": {
|
|
"istanbul": "0.3.9",
|
|
"mocha": "2.2.5"
|
|
},
|
|
"directories": {},
|
|
"dist": {
|
|
"shasum": "20f1336481b083cd75337992a16971aa2d906947",
|
|
"tarball": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz"
|
|
},
|
|
"engines": {
|
|
"node": ">= 0.8"
|
|
},
|
|
"files": [
|
|
"HISTORY.md",
|
|
"LICENSE",
|
|
"index.js"
|
|
],
|
|
"gitHead": "34babcb58126a416fcf5205768204f2e12699dda",
|
|
"homepage": "https://github.com/jshttp/on-finished#readme",
|
|
"license": "MIT",
|
|
"maintainers": [
|
|
{
|
|
"name": "dougwilson",
|
|
"email": "doug@somethingdoug.com"
|
|
},
|
|
{
|
|
"name": "jongleberry",
|
|
"email": "jonathanrichardong@gmail.com"
|
|
}
|
|
],
|
|
"name": "on-finished",
|
|
"optionalDependencies": {},
|
|
"readme": "# on-finished\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 callback when a HTTP request closes, finishes, or errors.\n\n## Install\n\n```sh\n$ npm install on-finished\n```\n\n## API\n\n```js\nvar onFinished = require('on-finished')\n```\n\n### onFinished(res, listener)\n\nAttach a listener to listen for the response to finish. The listener will\nbe invoked only once when the response finished. If the response finished\nto an error, the first argument will contain the error. If the response\nhas already finished, the listener will be invoked.\n\nListening to the end of a response would be used to close things associated\nwith the response, like open files.\n\nListener is invoked as `listener(err, res)`.\n\n```js\nonFinished(res, function (err, res) {\n // clean up open fds, etc.\n // err contains the error is request error'd\n})\n```\n\n### onFinished(req, listener)\n\nAttach a listener to listen for the request to finish. The listener will\nbe invoked only once when the request finished. If the request finished\nto an error, the first argument will contain the error. If the request\nhas already finished, the listener will be invoked.\n\nListening to the end of a request would be used to know when to continue\nafter reading the data.\n\nListener is invoked as `listener(err, req)`.\n\n```js\nvar data = ''\n\nreq.setEncoding('utf8')\nres.on('data', function (str) {\n data += str\n})\n\nonFinished(req, function (err, req) {\n // data is read unless there is err\n})\n```\n\n### onFinished.isFinished(res)\n\nDetermine if `res` is already finished. This would be useful to check and\nnot even start certain operations if the response has already finished.\n\n### onFinished.isFinished(req)\n\nDetermine if `req` is already finished. This would be useful to check and\nnot even start certain operations if the request has already finished.\n\n## Special Node.js requests\n\n### HTTP CONNECT method\n\nThe meaning of the `CONNECT` method from RFC 7231, section 4.3.6:\n\n> The CONNECT method requests that the recipient establish a tunnel to\n> the destination origin server identified by the request-target and,\n> if successful, thereafter restrict its behavior to blind forwarding\n> of packets, in both directions, until the tunnel is closed. Tunnels\n> are commonly used to create an end-to-end virtual connection, through\n> one or more proxies, which can then be secured using TLS (Transport\n> Layer Security, [RFC5246]).\n\nIn Node.js, these request objects come from the `'connect'` event on\nthe HTTP server.\n\nWhen this module is used on a HTTP `CONNECT` request, the request is\nconsidered \"finished\" immediately, **due to limitations in the Node.js\ninterface**. This means if the `CONNECT` request contains a request entity,\nthe request will be considered \"finished\" even before it has been read.\n\nThere is no such thing as a response object to a `CONNECT` request in\nNode.js, so there is no support for for one.\n\n### HTTP Upgrade request\n\nThe meaning of the `Upgrade` header from RFC 7230, section 6.1:\n\n> The \"Upgrade\" header field is intended to provide a simple mechanism\n> for transitioning from HTTP/1.1 to some other protocol on the same\n> connection.\n\nIn Node.js, these request objects come from the `'upgrade'` event on\nthe HTTP server.\n\nWhen this module is used on a HTTP request with an `Upgrade` header, the\nrequest is considered \"finished\" immediately, **due to limitations in the\nNode.js interface**. This means if the `Upgrade` request contains a request\nentity, the request will be considered \"finished\" even before it has been\nread.\n\nThere is no such thing as a response object to a `Upgrade` request in\nNode.js, so there is no support for for one.\n\n## Example\n\nThe following code ensures that file descriptors are always closed\nonce the response finishes.\n\n```js\nvar destroy = require('destroy')\nvar http = require('http')\nvar onFinished = require('on-finished')\n\nhttp.createServer(function onRequest(req, res) {\n var stream = fs.createReadStream('package.json')\n stream.pipe(res)\n onFinished(res, function (err) {\n destroy(stream)\n })\n})\n```\n\n## License\n\n[MIT](LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/on-finished.svg\n[npm-url]: https://npmjs.org/package/on-finished\n[node-version-image]: https://img.shields.io/node/v/on-finished.svg\n[node-version-url]: http://nodejs.org/download/\n[travis-image]: https://img.shields.io/travis/jshttp/on-finished/master.svg\n[travis-url]: https://travis-ci.org/jshttp/on-finished\n[coveralls-image]: https://img.shields.io/coveralls/jshttp/on-finished/master.svg\n[coveralls-url]: https://coveralls.io/r/jshttp/on-finished?branch=master\n[downloads-image]: https://img.shields.io/npm/dm/on-finished.svg\n[downloads-url]: https://npmjs.org/package/on-finished\n",
|
|
"readmeFilename": "README.md",
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "git+https://github.com/jshttp/on-finished.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": "2.3.0"
|
|
}
|