mirror of
https://github.com/nodemailer/wildduck.git
synced 2025-01-07 16:38:17 +08:00
Fix DEFLATE for short messages that weren't flushed to socket
This commit is contained in:
parent
9c68053987
commit
ba2a57e670
2 changed files with 14 additions and 1 deletions
|
@ -49,7 +49,10 @@ module.exports = {
|
|||
|
||||
this.writeStream.unpipe(this._socket);
|
||||
this._deflate.pipe(this._socket);
|
||||
let reading = false;
|
||||
let readNext = () => {
|
||||
reading = true;
|
||||
|
||||
let chunk;
|
||||
while ((chunk = this.writeStream.read()) !== null) {
|
||||
if (this._deflate && this._deflate.write(chunk) === false) {
|
||||
|
@ -60,8 +63,14 @@ module.exports = {
|
|||
if (this._deflate) {
|
||||
this._deflate.flush();
|
||||
}
|
||||
|
||||
reading = false;
|
||||
};
|
||||
this.writeStream.on('readable', readNext);
|
||||
this.writeStream.on('readable', () => {
|
||||
if (!reading) {
|
||||
readNext();
|
||||
}
|
||||
});
|
||||
|
||||
this._socket.unpipe(this._parser);
|
||||
this._socket.pipe(this._inflate).pipe(this._parser);
|
||||
|
|
|
@ -126,6 +126,10 @@ class IMAPConnection extends EventEmitter {
|
|||
send(payload, callback) {
|
||||
if (this._socket && this._socket.writable) {
|
||||
this[!this.compression ? '_socket' : '_deflate'].write(payload + '\r\n', 'binary', callback);
|
||||
if(this.compression){
|
||||
// make sure we transmit the message immediatelly
|
||||
this._deflate.flush();
|
||||
}
|
||||
this._server.logger.debug({
|
||||
tnx: 'send',
|
||||
cid: this.id
|
||||
|
|
Loading…
Reference in a new issue