Dovecot might answer DONE with some statistics:
IDLE OK Idle completed (0.001 + 0.093 + 0.092 secs).
The plus character passes RE_PRECEDING which leads to dead end
code-wise.
This fixes an edge case where the following happens:
* a body stream had data pushed to it such that the highWaterMark was reached
* when the body stream buffer dips below highWaterMark, _read() is called
* _read() tries to read more data from the socket, which pushes the last part of the body
* the last body part push() again calls _read() which in turn reads more data from the socket
* at this point the parser state is not stable because _body._read and _body are not reset yet, this causes the parser to potentially try to start reading the beginning of a response in the middle of the data for another fetch result for example
Fixes#345
Parser was not unregistering the 'readable' event listener from the old
socket, nor registering it to the new socket when setSocket() was
called. This caused event handling to stop during the STARTTLS handoff.
Signed-off-by: Kevin Locke <klocke@quantpost.com>
Some MUAs appear to break multi-byte characters across encoded word boundaries, which goes against RFC2047.
This change attempts to work around this by trying to concatenate broken encoded words that are separated by linear white space.
readable-stream proxies some events in wrap(). Since the Parser doesn't care about any events other than 'readable', we remove the troublesome proxied 'error' event.
Fixes#285
As the buffer was wiped before emitting the 'other' event, the
parser.on('other') event handler has no buffer data passed to it thus
can't detect the end of the IDLE and never calls the
self._processQueue() to get the stuff waiting in the queue to move.