Allow fetching of entire raw message (headers + body) by specifying an empty string for fetch()'s body property

fork
Brian White 13 years ago
parent 6c4b229ae5
commit 3b61bca20c

@ -559,7 +559,7 @@ ImapConnection.prototype.fetch = function(uids, options) {
else if (typeof options.request.body === 'boolean' && options.request.body === true)
toFetch = 'TEXT'; // fetches the whole entire message text (minus the headers), including all message parts
else if (typeof options.request.body === 'string') {
if (!/^([\d]+[\.]{0,1})*[\d]+$/.test(options.request.body))
if (options.request.body !== '' && !/^([\d]+[\.]{0,1})*[\d]+$/.test(options.request.body))
throw new Error("Invalid body partID format");
toFetch = options.request.body; // specific message part identifier, e.g. '1', '2', '1.1', '1.2', etc
}
@ -568,7 +568,7 @@ ImapConnection.prototype.fetch = function(uids, options) {
this._send('UID FETCH ' + uids.join(',') + ' (FLAGS INTERNALDATE'
+ (options.request.struct ? ' BODYSTRUCTURE' : '')
+ (toFetch ? ' BODY' + (!options.markSeen ? '.PEEK' : '')
+ (typeof toFetch === 'string' ? ' BODY' + (!options.markSeen ? '.PEEK' : '')
+ '[' + toFetch + ']' + bodyRange : '') + ')');
var imapFetcher = new ImapFetch();
this._state.requests[this._state.requests.length-1]._fetcher = imapFetcher;
@ -1206,28 +1206,6 @@ function convStr(str) {
return str;
}
function getNextIdxParen(str) {
var inQuote = false,
countParen = 0,
lastIndex = -1;
for (var i=1,len=str.length; i<len; i++) {
if (str[i-1] !== "\\" && str[i] === "\"")
inQuote = !inQuote;
else if (!inQuote) {
if (str[i] === '(')
countParen++;
else if (str[i] === ')') {
if (countParen === 0) {
lastIndex = i;
break;
} else
countParen--;
}
}
}
return lastIndex;
}
/**
* Adopted from jquery's extend method. Under the terms of MIT License.
*

Loading…
Cancel
Save