use on-socket-error
This commit is contained in:
parent
02409b9d5d
commit
879293f548
4 changed files with 4 additions and 17 deletions
|
@ -2,6 +2,7 @@ HEAD
|
|||
==================
|
||||
|
||||
* update co
|
||||
* use on-socket-error
|
||||
|
||||
0.1.1 / 2013-12-19
|
||||
==================
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
|
||||
var debug = require('debug')('koa:application');
|
||||
var onSocketError = require('on-socket-error');
|
||||
var Emitter = require('events').EventEmitter;
|
||||
var compose = require('koa-compose');
|
||||
var context = require('./context');
|
||||
|
@ -99,7 +100,7 @@ app.callback = function(){
|
|||
|
||||
return function(req, res){
|
||||
var ctx = self.createContext(req, res);
|
||||
ctx.onSocketError(ctx.onerror);
|
||||
onSocketError(ctx, ctx.onerror);
|
||||
fn.call(ctx, ctx.onerror);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -488,20 +488,4 @@ module.exports = {
|
|||
attachment: function() {
|
||||
return this.response.attachment.apply(this.response, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* Invoke `fn` on socket errors and
|
||||
* handle cleanup on response.
|
||||
*
|
||||
* @param {Function} fn
|
||||
* @api private
|
||||
*/
|
||||
|
||||
onSocketError: function(fn){
|
||||
var sock = this.socket;
|
||||
sock.once('error', fn);
|
||||
this.res.on('finish', function(){
|
||||
sock.removeListener('error', fn);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"on-socket-error": "~1.0.0",
|
||||
"co": "~3.0.0",
|
||||
"debug": "*",
|
||||
"mime": "~1.2.11",
|
||||
|
|
Loading…
Reference in a new issue