This commit is contained in:
TJ Holowaychuk 2014-04-14 15:36:39 -07:00
parent 95a78c3a44
commit 990caf4e71

View file

@ -3,15 +3,15 @@
* Module dependencies.
*/
var ensureErrorHandler = require('error-inject');
var debug = require('debug')('koa:response');
var escape = require('escape-html');
var onfinish = require('finished');
var status = require('statuses');
var destroy = require('dethroy');
var http = require('http');
var path = require('path');
var mime = require('mime');
var onFinished = require('finished');
var destroy = require('dethroy');
var inject = require('error-inject');
var basename = path.basename;
var extname = path.extname;
@ -132,12 +132,8 @@ module.exports = {
// stream
if ('function' == typeof val.pipe) {
// make sure all intermediate streams will destroy on finished
onFinished(this, destroy.bind(null, val));
// make sure all intermediate streams has an listenner on error
inject(val, this.ctx.onerror);
onfinish(this, destroy.bind(null, val));
ensureErrorHandler(val, this.ctx.onerror);
if (setType) this.type = 'bin';
return;
}