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() {
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) {
IncomingMessage.prototype._dump = function() {
this._dumped = true;
this.socket.parser.incoming = null;
- this._readableState.onread(null, null);
+ this.push(null);
this.socket.resume();
};
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