private InputStream getDecodedInputStream() { InputStream in; if ("quoted-printable".equalsIgnoreCase(getHeader("Content-Transfer-Encoding"))) { // Temporary workaround for AXIOM-467 while waiting for MIME4J 0.7.3: // use a copy of QuotedPrintableInputStream from the 0.7 branch. in = new QuotedPrintableInputStream(parser.getInputStream(), true); } else { in = parser.getDecodedInputStream(); } if (log.isDebugEnabled()) { in = new DebugInputStream(in, log); } return in; }
private byte[] mimeBodyContent() throws IOException, MimeException { final byte[] content; if (empty) { content = EMPTY; } else { parser.setRecursionMode(RecursionMode.M_FLAT); boolean valid = true; for (EntityState state = parser.getState(); state != EntityState.T_BODY && state != EntityState.T_START_MULTIPART; state = parser .next()) { if (state == EntityState.T_END_OF_STREAM) { valid = false; break; } } if (valid) { content = IOUtils.toByteArray(parser.getInputStream()); } else { content = EMPTY; } } return content; }
if (debug) { System.out.println("Body detected, contents = " + stream.getInputStream() + ", header data = " + stream.getBodyDescriptor());
content = IOUtils.toByteArray(parser.getInputStream()); } else { content = EMPTY;
stream = new IncomingAttachmentInputStream(parser.getInputStream(), this);
private static MimeDescriptorImpl simplePartDescriptor( final MimeTokenStream parser, Collection<MessageResult.Header> headers) throws IOException, MimeException { MaximalBodyDescriptor descriptor = (MaximalBodyDescriptor) parser .getBodyDescriptor(); final MimeDescriptorImpl mimeDescriptorImpl; if ("message".equalsIgnoreCase(descriptor.getMediaType()) && "rfc822".equalsIgnoreCase(descriptor.getSubType())) { final CountingInputStream messageStream = new CountingInputStream( parser.getDecodedInputStream()); MimeDescriptorImpl embeddedMessageDescriptor = build(messageStream); final int octetCount = messageStream.getOctetCount(); final int lineCount = messageStream.getLineCount(); mimeDescriptorImpl = createDescriptor(octetCount, lineCount, descriptor, embeddedMessageDescriptor, headers); } else { final InputStream body = parser.getInputStream(); long bodyOctets = 0; long lines = 0; for (int n = body.read(); n >= 0; n = body.read()) { if (n == '\r') { lines++; } bodyOctets++; } mimeDescriptorImpl = createDescriptor(bodyOctets, lines, descriptor, null, headers); } return mimeDescriptorImpl; }
bodyContent = mimeTokenStream.getDecodedInputStream(); } else { bodyContent = mimeTokenStream.getInputStream(); break OUTER; case T_EPILOGUE: handler.epilogue(mimeTokenStream.getInputStream()); break; case T_FIELD: break; case T_PREAMBLE: handler.preamble(mimeTokenStream.getInputStream()); break; case T_RAW_ENTITY: handler.raw(mimeTokenStream.getInputStream()); break; case T_START_BODYPART:
final CountingInputStream bodyStream = new CountingInputStream(parser.getInputStream()); bodyStream.readAll(); long lines = bodyStream.getLineCount(); next = parser.next(); if (next == EntityState.T_EPILOGUE) { final CountingInputStream epilogueStream = new CountingInputStream(parser.getInputStream()); epilogueStream.readAll(); lines += epilogueStream.getLineCount();