|
|
|
@ -326,12 +326,13 @@ ImapConnection.prototype.connect = function(loginCb) {
|
|
|
|
|
bodies = ['', null];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var shouldEmit;
|
|
|
|
|
for (body = 0, lenb = bodies.length; body < lenb; body += 2) {
|
|
|
|
|
fetches = requests[0].fetchers[bodies[body]];
|
|
|
|
|
val = bodies[body + 1];
|
|
|
|
|
for (var i=0, len=fetches.length; i<len; ++i) {
|
|
|
|
|
parsed = undefined;
|
|
|
|
|
if (!fetches[i]._msg)
|
|
|
|
|
if (shouldEmit = (!fetches[i]._msg))
|
|
|
|
|
fetches[i]._msg = new ImapMessage();
|
|
|
|
|
|
|
|
|
|
// copy message properties (uid, date, flags, etc)
|
|
|
|
@ -339,34 +340,32 @@ ImapConnection.prototype.connect = function(loginCb) {
|
|
|
|
|
k < lenk; ++k)
|
|
|
|
|
fetches[i]._msg[keys[k]] = details[keys[k]];
|
|
|
|
|
|
|
|
|
|
if (shouldEmit)
|
|
|
|
|
fetches[i].emit('message', fetches[i]._msg);
|
|
|
|
|
|
|
|
|
|
if (typeof val === 'number') {
|
|
|
|
|
// we streamed a body, e.g. {3}\r\nfoo
|
|
|
|
|
} else {
|
|
|
|
|
// no body was streamed
|
|
|
|
|
if (typeof val === 'string') {
|
|
|
|
|
// a body was given as a non-literal string, e.g. "foo"
|
|
|
|
|
// a body was given as a quoted, non-literal string,
|
|
|
|
|
// e.g. "foo"
|
|
|
|
|
if (RE_ISHEADER.test(bodies[body])) {
|
|
|
|
|
var parsed, data, headers;
|
|
|
|
|
//for (f = 0, lenf = fetches.length; f < lenf; ++f) {
|
|
|
|
|
if (fetches[i]._parse) {
|
|
|
|
|
if (parsed === undefined)
|
|
|
|
|
parsed = parsers.parseHeaders(val);
|
|
|
|
|
headers = parsed;
|
|
|
|
|
} else {
|
|
|
|
|
if (data === undefined)
|
|
|
|
|
data = new Buffer(val, 'binary');
|
|
|
|
|
headers = data;
|
|
|
|
|
}
|
|
|
|
|
fetches[i]._msg.emit('headers', headers);
|
|
|
|
|
//}
|
|
|
|
|
if (fetches[i]._parse) {
|
|
|
|
|
if (parsed === undefined)
|
|
|
|
|
parsed = parsers.parseHeaders(val);
|
|
|
|
|
headers = parsed;
|
|
|
|
|
} else {
|
|
|
|
|
if (data === undefined)
|
|
|
|
|
data = new Buffer(val, 'binary');
|
|
|
|
|
headers = data;
|
|
|
|
|
}
|
|
|
|
|
fetches[i]._msg.emit('headers', headers);
|
|
|
|
|
} else {
|
|
|
|
|
var data = new Buffer(val, 'binary');
|
|
|
|
|
//for (f = 0, lenf = fetches.length; f < lenf; ++f)
|
|
|
|
|
fetches[i]._msg.emit('data', data);
|
|
|
|
|
}
|
|
|
|
|
} else if (val === null) {
|
|
|
|
|
//for (f = 0, lenf = fetches.length; f < lenf; ++f)
|
|
|
|
|
fetches[i].emit('message', fetches[i]._msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|