james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r937677 - /james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java
Date Sat, 24 Apr 2010 19:15:17 GMT
Author: bago
Date: Sat Apr 24 19:15:17 2010
New Revision: 937677

URL: http://svn.apache.org/viewvc?rev=937677&view=rev
Log:
Avoid sequencing streams and simulating a contenttype header when we can easily simulate the
events (MIME4J-153 and MIME4J-128)

Modified:
    james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java

Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java?rev=937677&r1=937676&r2=937677&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java
(original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java
Sat Apr 24 19:15:17 2010
@@ -19,10 +19,8 @@
 
 package org.apache.james.mime4j.parser;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.SequenceInputStream;
 
 import org.apache.james.mime4j.MimeException;
 import org.apache.james.mime4j.codec.DecodeMonitor;
@@ -30,6 +28,7 @@ import org.apache.james.mime4j.stream.Bo
 import org.apache.james.mime4j.stream.MimeEntityConfig;
 import org.apache.james.mime4j.stream.MimeTokenStream;
 import org.apache.james.mime4j.stream.MutableBodyDescriptorFactory;
+import org.apache.james.mime4j.stream.RawField;
 
 /**
  * <p>
@@ -113,16 +112,16 @@ public class MimeStreamParser {
      * @throws MimeException if the message can not be processed
      * @throws IOException on I/O errors.
      */
-    public void parse(InputStream is) throws MimeException, IOException {
+    public void parse(InputStream inputStream) throws MimeException, IOException {
         boolean headless = mimeEntityConfig.getDefaultContentType() != null;
-        InputStream inputStream = is;
         if (headless) {
-            ByteArrayInputStream headerInputStream = new ByteArrayInputStream(
-                    ("Content-Type: " + mimeEntityConfig.getDefaultContentType()
-                            + "\r\n\r\n").getBytes("iso-8859-1"));
-            inputStream = new SequenceInputStream(headerInputStream, is);
+            mimeTokenStream.parseHeadless(inputStream, mimeEntityConfig.getDefaultContentType());
+            handler.startMessage();
+            handler.startHeader();
+            handler.field(new RawField("Content-Type", mimeEntityConfig.getDefaultContentType()));
+        } else {
+            mimeTokenStream.parse(inputStream);
         }
-        mimeTokenStream.parse(inputStream);
         OUTER: for (;;) {
             int state = mimeTokenStream.getState();
             switch (state) {



Mime
View raw message