1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-14 03:32:22 -05:00

IMAP: fix BODYSTRUCTURE, build message on full buffer, do not rely on partial buffer (header, body, ...)

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@707 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2009-09-08 22:25:39 +00:00
parent b36085f241
commit f1fa54311d

View File

@ -501,9 +501,7 @@ public class ImapConnection extends AbstractConnection {
bodystructure = true;
} else {
// thunderbird : send BODYSTRUCTURE
ByteArrayOutputStream baos = new ByteArrayOutputStream();
message.write(baos);
appendBodyStructure(buffer, baos);
appendBodyStructure(buffer, message);
}
} else if ("INTERNALDATE".equals(param) && message.date != null && message.date.length() > 0) {
try {
@ -524,7 +522,7 @@ public class ImapConnection extends AbstractConnection {
if (bodystructure) {
bodystructure = false;
// Apple Mail: need to build full bodystructure
appendBodyStructure(buffer, baos);
appendBodyStructure(buffer, message);
}
buffer.append(" RFC822.SIZE ").append(partOutputStream.size);
if ("BODY.PEEK[HEADER]".equals(param)) {
@ -563,7 +561,7 @@ public class ImapConnection extends AbstractConnection {
if (bodystructure) {
bodystructure = false;
// Apple Mail: need to build full bodystructure
appendBodyStructure(buffer, baos);
appendBodyStructure(buffer, message);
}
buffer.append(" RFC822.SIZE ").append(rfc822size).append(' ');
if ("BODY.PEEK[TEXT]".equals(param)) {
@ -587,7 +585,10 @@ public class ImapConnection extends AbstractConnection {
sendClient(buffer.toString());
}
protected void appendBodyStructure(StringBuilder buffer, ByteArrayOutputStream baos) throws IOException {
protected void appendBodyStructure(StringBuilder buffer, ExchangeSession.Message message) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
message.write(baos);
buffer.append(" BODYSTRUCTURE ");
try {
MimeMessage mimeMessage = new MimeMessage(null, new ByteArrayInputStream(baos.toByteArray()));