Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #44 from tellnes/async-unbuffer

emit end event if ended when manualy triggering unbuffer
  • Loading branch information...
commit 72a3133b0a49ab3067550832db8c13ea0803c5e4 2 parents 340cbdd + b1c9bf0
Charlie Robbins indexzero authored
10 examples/simple/simple.js
View
@@ -45,6 +45,16 @@ router.get('/custom_redirect', function() {
this.res.redirect('/foo', 301);
});
+router.get('/async', function () {
+ var self = this;
+ process.nextTick(function () {
+ self.req.on('end', function () {
+ self.res.end();
+ })
+ self.req.buffer = false;
+ });
+});
+
server.listen(9090);
console.log('union with director running on 9090');
1  lib/buffered-stream.js
View
@@ -47,6 +47,7 @@ Object.defineProperty(BufferedStream.prototype, 'buffer', {
if (!value && this.chunks) {
var self = this;
this.chunks.forEach(function (c) { self.emit('data', c) });
+ if (this.ended) this.emit('end');
this.size = 0;
delete this.chunks;
}
12 test/simple-test.js
View
@@ -72,6 +72,18 @@ vows.describe('union/simple').addBatch({
assert.equal(res.statusCode, 301);
assert.equal(res.headers.location, "http://localhost:9090/foo");
}
+ },
+ "a GET request to `/async`": {
+ topic: function() {
+ request.get({
+ url: 'http://localhost:9090/async',
+ timeout: 500
+ }, this.callback);
+ },
+ "it should not timeout": function (err, res, body) {
+ assert.ifError(err);
+ assert.equal(res.statusCode, 200);
+ }
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.