Merge pull request #291 from kevinoid/starttls-fixes

Fix broken STARTTLS
fork
Brian White 11 years ago
commit d028aadfca

@ -1463,8 +1463,10 @@ Connection.prototype._login = function() {
if (self.serverSupports('STARTTLS')
&& (self._config.autotls === 'always'
|| (self._config.autotls === 'required'
&& self.serverSupports('LOGINDISABLED'))))
&& self.serverSupports('LOGINDISABLED')))) {
self._starttls();
return;
}
if (self.serverSupports('LOGINDISABLED')) {
err = new Error('Logging in is disabled on this server');

@ -40,8 +40,6 @@ function Parser(stream, debug) {
this._ignoreReadable = false;
this.debug = debug;
this.setStream(stream);
var self = this;
this._cbReadable = function() {
if (self._ignoreReadable)
@ -51,12 +49,18 @@ function Parser(stream, debug) {
else
self._tryread();
};
this._stream.on('readable', this._cbReadable);
this.setStream(stream);
process.nextTick(this._cbReadable);
}
inherits(Parser, EventEmitter);
Parser.prototype.setStream = function(stream) {
if (this._stream) {
this._stream.removeListener('readable', this._cbReadable);
}
if (/^v0\.8\./.test(process.version)) {
this._stream = (new ReadableStream()).wrap(stream);
@ -66,6 +70,8 @@ Parser.prototype.setStream = function(stream) {
stream._events.error.pop();
} else
this._stream = stream;
this._stream.on('readable', this._cbReadable);
};
Parser.prototype._tryread = function(n) {

Loading…
Cancel
Save