|
|
|
@ -35,14 +35,14 @@ function Parser(stream, debug) {
|
|
|
|
|
this.setStream(stream);
|
|
|
|
|
|
|
|
|
|
var self = this;
|
|
|
|
|
function cb() {
|
|
|
|
|
if (self._literallen > 0)
|
|
|
|
|
this._cbReadable = function() {
|
|
|
|
|
if (self._literallen > 0 && !self._body)
|
|
|
|
|
self._tryread(self._literallen);
|
|
|
|
|
else
|
|
|
|
|
self._tryread();
|
|
|
|
|
}
|
|
|
|
|
this._stream.on('readable', cb);
|
|
|
|
|
process.nextTick(cb);
|
|
|
|
|
this._stream.on('readable', this._cbReadable);
|
|
|
|
|
process.nextTick(this._cbReadable);
|
|
|
|
|
}
|
|
|
|
|
inherits(Parser, EventEmitter);
|
|
|
|
|
|
|
|
|
@ -75,8 +75,10 @@ Parser.prototype._parse = function(data) {
|
|
|
|
|
} else {
|
|
|
|
|
this._literallen -= datalen;
|
|
|
|
|
var r = body.push(data);
|
|
|
|
|
if (!r && this._literallen > 0)
|
|
|
|
|
if (!r && this._literallen > 0) {
|
|
|
|
|
body._read = this._cbReadable;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
i = datalen;
|
|
|
|
|
}
|
|
|
|
|
if (this._literallen === 0) {
|
|
|
|
@ -166,9 +168,7 @@ Parser.prototype._resUntagged = function() {
|
|
|
|
|
var which = m[1], size = parseInt(m[2], 10);
|
|
|
|
|
this._literallen = size;
|
|
|
|
|
this._body = new ReadableStream();
|
|
|
|
|
this._body._read = function bodyread(n) {
|
|
|
|
|
self._tryread();
|
|
|
|
|
};
|
|
|
|
|
this._body._read = EMPTY_READCB;
|
|
|
|
|
m = RE_SEQNO.exec(this._buffer);
|
|
|
|
|
this._buffer = this._buffer.replace(RE_BODYLITERAL, '');
|
|
|
|
|
this.emit('body', this._body, {
|
|
|
|
|