mirror of
https://github.com/moparisthebest/davmail
synced 2025-02-28 09:21:49 -05:00
IMAP: implement subparts partial fetch
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@989 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
f0a7f1ae76
commit
4789993fb9
@ -596,26 +596,27 @@ public class ImapConnection extends AbstractConnection {
|
||||
// write headers only
|
||||
mimeMessage.writeTo(new PartOutputStream(baos, true, false, startIndex, maxSize));
|
||||
} else {
|
||||
int partIndex;
|
||||
// try to parse part index
|
||||
try {
|
||||
partIndex = Integer.parseInt(partIndexString);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new DavMailException("EXCEPTION_UNSUPPORTED_PARAMETER", param);
|
||||
MimePart bodyPart = mimeMessage;
|
||||
String[] partIndexStrings = partIndexString.split("\\.");
|
||||
for (String subPartIndexString:partIndexStrings) {
|
||||
int subPartIndex;
|
||||
// try to parse part index
|
||||
try {
|
||||
subPartIndex = Integer.parseInt(subPartIndexString);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new DavMailException("EXCEPTION_INVALID_PARAMETER", param);
|
||||
}
|
||||
|
||||
Object mimeBody = bodyPart.getContent();
|
||||
if (mimeBody instanceof MimeMultipart) {
|
||||
MimeMultipart multiPart = (MimeMultipart) mimeBody;
|
||||
bodyPart = (MimePart) multiPart.getBodyPart(subPartIndex - 1);
|
||||
} else if (subPartIndex != 1) {
|
||||
throw new DavMailException("EXCEPTION_INVALID_PARAMETER", param);
|
||||
}
|
||||
}
|
||||
|
||||
Object mimeBody = mimeMessage.getContent();
|
||||
MimePart bodyPart;
|
||||
if (mimeBody instanceof MimeMultipart) {
|
||||
MimeMultipart multiPart = (MimeMultipart) mimeBody;
|
||||
bodyPart = (MimePart) multiPart.getBodyPart(partIndex - 1);
|
||||
} else if (partIndex == 1) {
|
||||
// no multipart, single body
|
||||
bodyPart = mimeMessage;
|
||||
} else {
|
||||
throw new DavMailException("EXCEPTION_INVALID_PARAMETER", param);
|
||||
}
|
||||
// write selected part
|
||||
// write selected part, without headers
|
||||
bodyPart.getDataHandler().writeTo(new PartialOutputStream(baos, startIndex, maxSize));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user