Permalink
Browse files

handle unilateral responses

  • Loading branch information...
1 parent bbb4fdc commit 047c6506ad9ff9fe8771199de85fbcd20f044421 @mscdex committed Dec 18, 2012
Showing with 6 additions and 3 deletions.
  1. +6 −3 lib/ftp.js
View
@@ -249,9 +249,12 @@ FTP.prototype.connect = function(options) {
reRmLeadCode = RegExp(reRmLeadCode, 'g');
self._buffer = self._buffer.replace(reRmLeadCode, '$1').trim();
- if (retval === RETVAL.ERR_TEMP || retval === RETVAL.ERR_PERM)
- self._curReq.cb(makeError(self._buffer, code), undefined, code);
- else
+ if (retval === RETVAL.ERR_TEMP || retval === RETVAL.ERR_PERM) {
+ if (self._curReq)
+ self._curReq.cb(makeError(self._buffer, code), undefined, code);
+ else
+ self.emit('error', makeError(self._buffer, code));
+ } else if (self._curReq)
self._curReq.cb(undefined, self._buffer, code);
self._buffer = '';

0 comments on commit 047c650

Please sign in to comment.