mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 11:42:16 -05:00
Save multi part epilogue in MimeMultipart
This commit is contained in:
parent
d1d7b60a09
commit
3919c9d2d6
@ -2,6 +2,7 @@
|
||||
package com.fsck.k9.mail.internet;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@ -14,6 +15,7 @@ import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.james.mime4j.MimeException;
|
||||
import org.apache.james.mime4j.dom.field.DateTimeField;
|
||||
import org.apache.james.mime4j.field.DefaultFieldParser;
|
||||
@ -575,6 +577,10 @@ public class MimeMessage extends Message {
|
||||
|
||||
@Override
|
||||
public void epilogue(InputStream is) throws IOException {
|
||||
expect(MimeMultipart.class);
|
||||
ByteArrayOutputStream epilogue = new ByteArrayOutputStream();
|
||||
IOUtils.copy(is, epilogue);
|
||||
((MimeMultipart) stack.peek()).setEpilogue(epilogue.toByteArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -11,6 +11,7 @@ import java.util.Random;
|
||||
|
||||
public class MimeMultipart extends Multipart {
|
||||
private String mPreamble;
|
||||
private byte[] mEpilogue;
|
||||
|
||||
private String mContentType;
|
||||
|
||||
@ -53,6 +54,10 @@ public class MimeMultipart extends Multipart {
|
||||
this.mPreamble = preamble;
|
||||
}
|
||||
|
||||
public void setEpilogue(byte[] epilogue) {
|
||||
mEpilogue = epilogue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return mContentType;
|
||||
@ -90,6 +95,9 @@ public class MimeMultipart extends Multipart {
|
||||
writer.write(mBoundary);
|
||||
writer.write("--\r\n");
|
||||
writer.flush();
|
||||
if (mEpilogue != null) {
|
||||
out.write(mEpilogue);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -42,7 +42,8 @@ public class ReconstructMessageTest extends AndroidTestCase {
|
||||
"VGhpcyBpcyBhIHRl\r\n" +
|
||||
"c3QgbWVzc2FnZQ==\r\n" +
|
||||
"\r\n" +
|
||||
"------Boundary--\r\n";
|
||||
"------Boundary--\r\n" +
|
||||
"Hi, I'm the epilogue";
|
||||
|
||||
BinaryTempFileBody.setTempDirectory(getContext().getCacheDir());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user