mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-12 10:42:21 -05:00
IMAP: fix double header content and optimize header fetch with Fetchmail
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@2132 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
44e6900ec6
commit
8daec02f33
@ -1946,9 +1946,13 @@ public abstract class ExchangeSession {
|
|||||||
// message not loaded, try to get headers only
|
// message not loaded, try to get headers only
|
||||||
InputStream headers = getMimeHeaders();
|
InputStream headers = getMimeHeaders();
|
||||||
if (headers != null) {
|
if (headers != null) {
|
||||||
|
if (headerNames == null) {
|
||||||
|
result = new InternetHeaders(headers).getAllHeaderLines();
|
||||||
|
} else {
|
||||||
result = new InternetHeaders(headers).getMatchingHeaderLines(headerNames);
|
result = new InternetHeaders(headers).getMatchingHeaderLines(headerNames);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -783,7 +783,9 @@ public class ImapConnection extends AbstractConnection {
|
|||||||
protected void loadMessage() throws IOException, MessagingException {
|
protected void loadMessage() throws IOException, MessagingException {
|
||||||
if (!message.isLoaded()) {
|
if (!message.isLoaded()) {
|
||||||
// flush current buffer
|
// flush current buffer
|
||||||
os.write(buffer.toString().getBytes());
|
String flushString = buffer.toString();
|
||||||
|
LOGGER.debug(flushString);
|
||||||
|
os.write(flushString.getBytes());
|
||||||
buffer.setLength(0);
|
buffer.setLength(0);
|
||||||
MessageLoadThread.loadMimeMessage(message, os);
|
MessageLoadThread.loadMimeMessage(message, os);
|
||||||
}
|
}
|
||||||
@ -873,7 +875,7 @@ public class ImapConnection extends AbstractConnection {
|
|||||||
|
|
||||||
// try to parse message part index
|
// try to parse message part index
|
||||||
String partIndexString = StringUtil.getToken(param, "[", "]");
|
String partIndexString = StringUtil.getToken(param, "[", "]");
|
||||||
if ("".equals(partIndexString) || partIndexString == null) {
|
if (("".equals(partIndexString) || partIndexString == null) && !"RFC822.HEADER".equals(param)) {
|
||||||
// write message with headers
|
// write message with headers
|
||||||
partOutputStream = new PartialOutputStream(baos, startIndex, maxSize);
|
partOutputStream = new PartialOutputStream(baos, startIndex, maxSize);
|
||||||
partInputStream = messageWrapper.getRawInputStream();
|
partInputStream = messageWrapper.getRawInputStream();
|
||||||
@ -884,9 +886,8 @@ public class ImapConnection extends AbstractConnection {
|
|||||||
} else if ("RFC822.HEADER".equals(param) || partIndexString.startsWith("HEADER")) {
|
} else if ("RFC822.HEADER".equals(param) || partIndexString.startsWith("HEADER")) {
|
||||||
// Header requested fetch headers
|
// Header requested fetch headers
|
||||||
String[] requestedHeaders = getRequestedHeaders(partIndexString);
|
String[] requestedHeaders = getRequestedHeaders(partIndexString);
|
||||||
if (requestedHeaders != null) {
|
|
||||||
// OSX Lion special flags request
|
// OSX Lion special flags request
|
||||||
if (requestedHeaders.length == 1 && "content-class".equals(requestedHeaders[0]) && message.contentClass != null) {
|
if (requestedHeaders != null && requestedHeaders.length == 1 && "content-class".equals(requestedHeaders[0]) && message.contentClass != null) {
|
||||||
baos.write("Content-class: ".getBytes("UTF-8"));
|
baos.write("Content-class: ".getBytes("UTF-8"));
|
||||||
baos.write(message.contentClass.getBytes("UTF-8"));
|
baos.write(message.contentClass.getBytes("UTF-8"));
|
||||||
baos.write(13);
|
baos.write(13);
|
||||||
@ -899,11 +900,6 @@ public class ImapConnection extends AbstractConnection {
|
|||||||
baos.write(10);
|
baos.write(10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// write headers only
|
|
||||||
partOutputStream = new PartOutputStream(baos, true, false, startIndex, maxSize);
|
|
||||||
partInputStream = messageWrapper.getRawInputStream();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
MimePart bodyPart = messageWrapper.getMimeMessage();
|
MimePart bodyPart = messageWrapper.getMimeMessage();
|
||||||
String[] partIndexStrings = partIndexString.split("\\.");
|
String[] partIndexStrings = partIndexString.split("\\.");
|
||||||
|
@ -508,4 +508,11 @@ public class TestImap extends AbstractImapTestCase {
|
|||||||
assertEquals(". OK UID FETCH completed", readFullAnswer("."));
|
assertEquals(". OK UID FETCH completed", readFullAnswer("."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testDoubleHeaderFetch() throws IOException {
|
||||||
|
writeLine(". SELECT INBOX");
|
||||||
|
assertEquals(". OK [READ-WRITE] SELECT completed", readFullAnswer("."));
|
||||||
|
writeLine(". UID FETCH 1:* RFC822.HEADER");
|
||||||
|
assertEquals(". OK UID FETCH completed", readFullAnswer("."));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user