Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'gh-12'

  • Loading branch information...
commit 80958977e896ac7e2046edb2da2ff5f4232878e4 2 parents d4dd52e + bc6076e
@indexzero indexzero authored
View
19 lib/buffered-stream.js
@@ -34,10 +34,24 @@ var BufferedStream = module.exports = function (limit) {
this.chunks = [];
this.writable = true;
this.readable = true;
+ this._buffer = true;
};
util.inherits(BufferedStream, stream.Stream);
+Object.defineProperty(BufferedStream.prototype, 'buffer', {
+ get: function () {
+ return this._buffer;
+ },
+ set: function (value) {
+ if (!value) {
+ delete this.chunks
+ }
+
+ this._buffer = value;
+ }
+});
+
BufferedStream.prototype.pipe = function () {
var self = this;
if (self.resume) {
@@ -91,7 +105,10 @@ BufferedStream.prototype.write = function (chunk) {
BufferedStream.prototype.end = function () {
this.readable = false;
this.ended = true;
- this.emit('end');
+
+ if (!this.chunks) {
+ this.emit('end');
+ }
};
BufferedStream.prototype.close = function () {
View
1  test/fixtures/pipe-write-test.txt
@@ -0,0 +1 @@
+hello worldhello world
View
12 test/streaming-test.js
@@ -14,12 +14,18 @@ vows.describe('union/streaming').addBatch({
union.createServer({
before: [
function (req, res, next) {
+ var chunks = '';
+
+ req.buffer = false;
+ req.on('data', function (chunk) {
+ chunks += chunk;
+ });
+
req.on('end', function () {
- self.callback(null, req.chunks);
+ self.callback(null, chunks);
});
}
- ],
- stream: true
+ ]
}).listen(9000, function () {
request.post('http://localhost:9000').write('hello world');
});
Please sign in to comment.
Something went wrong with that request. Please try again.