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