Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

emit end event if ended when manualy triggering unbuffer #44

Merged
merged 1 commit into from

2 participants

Christian Tellnes Charlie Robbins
Christian Tellnes

With this change it is possible to use union together with an asynchronous middleware and nodejitsu/node-http-proxy.

Charlie Robbins indexzero merged commit 72a3133 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
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);
+ }
}
}
}
Something went wrong with that request. Please try again.