mirror of
https://github.com/moparisthebest/davmail
synced 2024-11-16 06:15:09 -05:00
IMAP: exclude Mutt header request from size optimization
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@2084 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
565eede913
commit
ba7619b5cf
@ -726,7 +726,9 @@ public class ImapConnection extends AbstractConnection {
|
|||||||
buffer.append(" FLAGS (").append(message.getImapFlags()).append(')');
|
buffer.append(" FLAGS (").append(message.getImapFlags()).append(')');
|
||||||
} else if ("RFC822.SIZE".equals(param)) {
|
} else if ("RFC822.SIZE".equals(param)) {
|
||||||
int size;
|
int size;
|
||||||
if (parameters.indexOf("BODY.PEEK[HEADER.FIELDS (") >= 0) {
|
if (parameters.indexOf("BODY.PEEK[HEADER.FIELDS (") >= 0
|
||||||
|
// exclude mutt header request
|
||||||
|
&& parameters.indexOf("X-LABEL") < 0) {
|
||||||
// Header request, send approximate size
|
// Header request, send approximate size
|
||||||
size = message.size;
|
size = message.size;
|
||||||
} else {
|
} else {
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
package davmail.imap;
|
package davmail.imap;
|
||||||
|
|
||||||
import davmail.Settings;
|
import davmail.Settings;
|
||||||
|
import davmail.exchange.ExchangeSession;
|
||||||
|
|
||||||
import javax.mail.MessagingException;
|
import javax.mail.MessagingException;
|
||||||
import javax.mail.Session;
|
import javax.mail.Session;
|
||||||
@ -26,6 +27,9 @@ import javax.mail.internet.MimeMessage;
|
|||||||
import javax.mail.util.SharedByteArrayInputStream;
|
import javax.mail.util.SharedByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,6 +38,14 @@ import java.util.Random;
|
|||||||
@SuppressWarnings({"JavaDoc", "UseOfSystemOutOrSystemErr"})
|
@SuppressWarnings({"JavaDoc", "UseOfSystemOutOrSystemErr"})
|
||||||
public class TestImap extends AbstractImapTestCase {
|
public class TestImap extends AbstractImapTestCase {
|
||||||
|
|
||||||
|
protected String getLastMonth() {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.add(Calendar.MONTH, -1);
|
||||||
|
SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy", Locale.ENGLISH);
|
||||||
|
formatter.setTimeZone(ExchangeSession.GMT_TIMEZONE);
|
||||||
|
return formatter.format(calendar.getTime());
|
||||||
|
}
|
||||||
|
|
||||||
public void testListFolders() throws IOException {
|
public void testListFolders() throws IOException {
|
||||||
writeLine(". LSUB \"\" \"*\"");
|
writeLine(". LSUB \"\" \"*\"");
|
||||||
assertEquals(". OK LSUB completed", readFullAnswer("."));
|
assertEquals(". OK LSUB completed", readFullAnswer("."));
|
||||||
@ -451,4 +463,29 @@ public class TestImap extends AbstractImapTestCase {
|
|||||||
assertEquals(". OK UID FETCH completed", readFullAnswer("."));
|
assertEquals(". OK UID FETCH completed", readFullAnswer("."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testFetchHeadersInboxMutt() throws IOException {
|
||||||
|
writeLine(". SELECT INBOX");
|
||||||
|
assertEquals(". OK [READ-WRITE] SELECT completed", readFullAnswer("."));
|
||||||
|
writeLine(". UID SEARCH (SINCE \""+getLastMonth()+"\")");
|
||||||
|
String messageLine = readLine();
|
||||||
|
int uidIndex = messageLine.indexOf(" ", "* SEARCH".length()) + 1;
|
||||||
|
messageUid = messageLine.substring(uidIndex, messageLine.indexOf(' ', uidIndex));
|
||||||
|
assertEquals(". OK SEARCH completed", readFullAnswer("."));
|
||||||
|
System.out.println(messageUid);
|
||||||
|
writeLine(". UID FETCH "+messageUid+":* (UID FLAGS INTERNALDATE RFC822.SIZE BODY.PEEK[HEADER.FIELDS (DATE FROM SUBJECT TO CC MESSAGE-ID REFERENCES CONTENT-TYPE CONTENT-DESCRIPTION IN-REPLY-TO REPLY-TO LINES LIST-POST X-LABEL)])");
|
||||||
|
assertEquals(". OK UID FETCH completed", readFullAnswer("."));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testFetchHeadersInboxOSX() throws IOException {
|
||||||
|
writeLine(". SELECT INBOX");
|
||||||
|
assertEquals(". OK [READ-WRITE] SELECT completed", readFullAnswer("."));
|
||||||
|
writeLine(". UID SEARCH (SINCE \""+getLastMonth()+"\")");
|
||||||
|
String messageLine = readLine();
|
||||||
|
int uidIndex = messageLine.indexOf(" ", "* SEARCH".length()) + 1;
|
||||||
|
messageUid = messageLine.substring(uidIndex, messageLine.indexOf(' ', uidIndex));
|
||||||
|
assertEquals(". OK SEARCH completed", readFullAnswer("."));
|
||||||
|
System.out.println(messageUid);
|
||||||
|
writeLine(". UID FETCH "+messageUid+":* (INTERNALDATE UID RFC822.SIZE FLAGS BODY.PEEK[HEADER.FIELDS (date subject from to cc message-id in-reply-to references x-priority x-uniform-type-identifier x-universally-unique-identifier received-spf x-spam-status x-spam-flag)])");
|
||||||
|
assertEquals(". OK UID FETCH completed", readFullAnswer("."));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user