diff options
author | isaacs <i@izs.me> | 2013-01-07 20:23:07 -0800 |
---|---|---|
committer | isaacs <i@izs.me> | 2013-01-10 13:50:06 -0800 |
commit | bc8feb151c731f5862a02fccb58638105b44d45b (patch) | |
tree | df10e4ca2f5b8c597f09921ad5995ba3328d2a2a /lib/http.js | |
parent | 840401c024a31e35515e76155693131f6de0ea86 (diff) | |
download | android-node-v8-bc8feb151c731f5862a02fccb58638105b44d45b.tar.gz android-node-v8-bc8feb151c731f5862a02fccb58638105b44d45b.tar.bz2 android-node-v8-bc8feb151c731f5862a02fccb58638105b44d45b.zip |
http: Use stream.push() instead of touching _readableState
Diffstat (limited to 'lib/http.js')
-rw-r--r-- | lib/http.js | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/lib/http.js b/lib/http.js index 4114f213c3..1bf85d234a 100644 --- a/lib/http.js +++ b/lib/http.js @@ -122,17 +122,15 @@ function parserOnBody(b, start, len) { if (!stream) return; - var rs = stream._readableState; var socket = stream.socket; // pretend this was the result of a stream._read call. - if (len > 0) { + if (len > 0 && !stream._dumped) { var slice = b.slice(start, start + len); - rs.onread(null, slice); + var ret = stream.push(slice); + if (!ret) + socket.pause(); } - - if (rs.length >= rs.highWaterMark) - socket.pause(); } function parserOnMessageComplete() { @@ -155,14 +153,12 @@ function parserOnMessageComplete() { if (!stream.upgrade) // For upgraded connections, also emit this after parser.execute - stream._readableState.onread(null, null); + stream.push(null); } - if (stream && - !stream._readableState.endEmitted && - !parser.incoming._pendings.length) { + if (stream && !parser.incoming._pendings.length) { // For emit end event - stream._readableState.onread(null, null); + stream.push(null); } if (parser.socket.readable) { @@ -402,7 +398,7 @@ IncomingMessage.prototype._addHeaderLine = function(field, value) { IncomingMessage.prototype._dump = function() { this._dumped = true; this.socket.parser.incoming = null; - this._readableState.onread(null, null); + this.push(null); this.socket.resume(); }; @@ -1363,7 +1359,7 @@ function socketCloseListener() { res.on('end', function() { res.emit('close'); }); - res._readableState.onread(null, null); + res.push(null); } else if (!req.res && !req._hadError) { // This socket error fired before we started to // receive a response. The error needs to |