hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r675712 - in /httpcomponents/httpclient/trunk: ./ module-httpmime/ module-httpmime/src/main/java/org/apache/http/entity/mime/ module-httpmime/src/main/java/org/apache/http/entity/mime/content/ module-httpmime/src/test/java/org/apache/http/e...
Date Thu, 10 Jul 2008 20:16:33 GMT
Author: olegk
Date: Thu Jul 10 13:16:33 2008
New Revision: 675712

URL: http://svn.apache.org/viewvc?rev=675712&view=rev
Log:
HTTPCLIENT-784: Improved browser compatibility mode of the HttpMultipart class; upgraded mime4j
dependency to version 0.4-SNAPSHOT

Removed:
    httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/ContentDescriptor.java
    httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/RFC822Header.java
Modified:
    httpcomponents/httpclient/trunk/module-httpmime/pom.xml
    httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPart.java
    httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/HttpMultipart.java
    httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/MultipartEntity.java
    httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/content/ContentBody.java
    httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/content/FileBody.java
    httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/content/InputStreamBody.java
    httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/content/StringBody.java
    httpcomponents/httpclient/trunk/module-httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartForm.java
    httpcomponents/httpclient/trunk/pom.xml

Modified: httpcomponents/httpclient/trunk/module-httpmime/pom.xml
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-httpmime/pom.xml?rev=675712&r1=675711&r2=675712&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-httpmime/pom.xml (original)
+++ httpcomponents/httpclient/trunk/module-httpmime/pom.xml Thu Jul 10 13:16:33 2008
@@ -70,24 +70,11 @@
       <version>${mime4j.version}</version>
     </dependency>
     <dependency>
-      <groupId>commons-io</groupId>
-      <artifactId>commons-io</artifactId>
-      <version>${commons-io.version}</version>
-    </dependency>
-    <dependency>
       <groupId>commons-logging</groupId>
       <artifactId>commons-logging</artifactId>
       <version>${commons-logging.version}</version>
     </dependency>
     <dependency>
-    <!-- To be removed as soon as apache-mime4j is upgraded to version 0.4
-     or GUMP has been made capable of handling of transitive dependencies
-    -->
-      <groupId>log4j</groupId>
-      <artifactId>log4j</artifactId>
-      <version>1.2.14</version>
-    </dependency>
-    <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <version>${junit.version}</version>

Modified: httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPart.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPart.java?rev=675712&r1=675711&r2=675712&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPart.java
(original)
+++ httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPart.java
Thu Jul 10 13:16:33 2008
@@ -32,6 +32,7 @@
 package org.apache.http.entity.mime;
 
 import org.apache.http.entity.mime.content.ContentBody;
+import org.apache.james.mime4j.ContentDescriptor;
 import org.apache.james.mime4j.field.Field;
 import org.apache.james.mime4j.message.BodyPart;
 import org.apache.james.mime4j.message.Header;
@@ -57,7 +58,7 @@
         }
         this.name = name;
         
-        Header header = new RFC822Header();
+        Header header = new Header();
         setHeader(header);
         setBody(body);
 
@@ -92,7 +93,7 @@
             buffer.append(desc.getMimeType());
             if (desc.getCharset() != null) {
                 buffer.append("; charset=");
-                buffer.append(desc.getCharset().name());
+                buffer.append(desc.getCharset());
             }
             getHeader().addField(Field.parse(buffer.toString()));
         }

Modified: httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/HttpMultipart.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/HttpMultipart.java?rev=675712&r1=675711&r2=675712&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/HttpMultipart.java
(original)
+++ httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/HttpMultipart.java
Thu Jul 10 13:16:33 2008
@@ -32,15 +32,16 @@
 package org.apache.http.entity.mime;
 
 import java.io.BufferedWriter;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.nio.charset.Charset;
 import java.util.List;
 
-import org.apache.commons.io.output.ByteArrayOutputStream;
 import org.apache.http.entity.mime.content.ContentBody;
 import org.apache.http.protocol.HTTP;
+import org.apache.james.mime4j.MimeException;
 import org.apache.james.mime4j.field.ContentTypeField;
 import org.apache.james.mime4j.field.Field;
 import org.apache.james.mime4j.message.Body;
@@ -48,6 +49,7 @@
 import org.apache.james.mime4j.message.Entity;
 import org.apache.james.mime4j.message.Multipart;
 import org.apache.james.mime4j.util.CharsetUtil;
+import org.apache.james.mime4j.util.MessageUtils;
 
 /**
  * An extension of the mime4j standard {@link Multipart} class, which is
@@ -60,8 +62,8 @@
 
     private HttpMultipartMode mode;
     
-    public HttpMultipart() {
-        super();
+    public HttpMultipart(final String subType) {
+        super(subType);
         this.mode = HttpMultipartMode.STRICT;
     }
     
@@ -101,7 +103,10 @@
         return cField.getBoundary();
     }
 
-    private void writeTo(final OutputStream out, boolean writeContent) throws IOException
{
+    private void doWriteTo(
+        final HttpMultipartMode mode, 
+        final OutputStream out, 
+        boolean writeContent) throws IOException {
         
         List<?> bodyParts = getBodyParts();
         Charset charset = getCharset();
@@ -111,10 +116,13 @@
                 new OutputStreamWriter(out, charset),
                 8192);
         
-        switch (this.mode) {
+        switch (mode) {
         case STRICT:
-            writer.write(getPreamble());
-            writer.write("\r\n");
+            String preamble = getPreamble();
+            if (preamble != null && preamble.length() != 0) {
+                writer.write(preamble);
+                writer.write("\r\n");
+            }
 
             for (int i = 0; i < bodyParts.size(); i++) {
                 writer.write("--");
@@ -122,9 +130,9 @@
                 writer.write("\r\n");
                 writer.flush();
                 BodyPart part = (BodyPart) bodyParts.get(i);
-                part.getHeader().writeTo(out);
+                part.getHeader().writeTo(out, MessageUtils.STRICT_IGNORE);
                 if (writeContent) {
-                    part.getBody().writeTo(out);
+                    part.getBody().writeTo(out, MessageUtils.STRICT_IGNORE);
                 }
                 writer.write("\r\n");
             }
@@ -132,8 +140,11 @@
             writer.write("--");
             writer.write(boundary);
             writer.write("--\r\n");
-            writer.write(getEpilogue());
-            writer.write("\r\n");
+            String epilogue = getEpilogue();
+            if (epilogue != null && epilogue.length() != 0) {
+                writer.write(epilogue);
+                writer.write("\r\n");
+            }
             writer.flush();
             break;
         case BROWSER_COMPATIBLE:
@@ -142,8 +153,6 @@
             // (2) Only write Content-Disposition 
             // (3) Use content charset
             
-            writer.write("\r\n");
-
             for (int i = 0; i < bodyParts.size(); i++) {
                 writer.write("--");
                 writer.write(boundary);
@@ -157,7 +166,7 @@
                 writer.write("\r\n");
                 writer.flush();
                 if (writeContent) {
-                    part.getBody().writeTo(out);
+                    part.getBody().writeTo(out, MessageUtils.LENIENT);
                 }
                 
                 writer.write("\r\n");
@@ -166,7 +175,6 @@
             writer.write("--");
             writer.write(boundary);
             writer.write("--\r\n");
-            writer.write("\r\n");
             writer.flush();
             break;
         }
@@ -179,9 +187,17 @@
      * 
      * @see #getMode()
      */
-    @Override
     public void writeTo(final OutputStream out) throws IOException {
-        writeTo(out, true);
+        doWriteTo(this.mode, out, true);
+    }
+
+    @Override
+    public void writeTo(final OutputStream out, int mode) throws IOException, MimeException
{
+        if (mode == MessageUtils.LENIENT) {
+            doWriteTo(HttpMultipartMode.BROWSER_COMPATIBLE, out, true);
+        } else {
+            doWriteTo(HttpMultipartMode.STRICT, out, true);
+        }
     }
 
     /**
@@ -218,7 +234,7 @@
             
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         try {
-            writeTo(out, false);
+            doWriteTo(this.mode, out, false);
             byte[] extra = out.toByteArray();
             return contentLen + extra.length;
         } catch (IOException ex) {

Modified: httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/MultipartEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/MultipartEntity.java?rev=675712&r1=675711&r2=675712&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/MultipartEntity.java
(original)
+++ httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/MultipartEntity.java
Thu Jul 10 13:16:33 2008
@@ -73,14 +73,15 @@
             final String boundary,
             final Charset charset) {
         super();
-        this.multipart = new HttpMultipart();
+        this.multipart = new HttpMultipart("form-data");
         this.contentType = new BasicHeader(
                 HTTP.CONTENT_TYPE,
                 generateContentType(boundary, charset));
         this.dirty = true;
         
         Message message = new Message();
-        org.apache.james.mime4j.message.Header header = new RFC822Header();
+        org.apache.james.mime4j.message.Header header = 
+          new org.apache.james.mime4j.message.Header();
         header.addField(
                 Field.parse("Content-Type: " + this.contentType.getValue()));
         message.setHeader(header);

Modified: httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/content/ContentBody.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/content/ContentBody.java?rev=675712&r1=675711&r2=675712&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/content/ContentBody.java
(original)
+++ httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/content/ContentBody.java
Thu Jul 10 13:16:33 2008
@@ -31,7 +31,7 @@
 
 package org.apache.http.entity.mime.content;
 
-import org.apache.http.entity.mime.ContentDescriptor;
+import org.apache.james.mime4j.ContentDescriptor;
 import org.apache.james.mime4j.message.Body;
 
 public interface ContentBody extends Body, ContentDescriptor {

Modified: httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/content/FileBody.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/content/FileBody.java?rev=675712&r1=675711&r2=675712&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/content/FileBody.java
(original)
+++ httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/content/FileBody.java
Thu Jul 10 13:16:33 2008
@@ -36,9 +36,9 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.nio.charset.Charset;
+import java.util.Collections;
+import java.util.Map;
 
-import org.apache.commons.io.IOUtils;
 import org.apache.http.entity.mime.MIME;
 import org.apache.james.mime4j.message.AbstractBody;
 import org.apache.james.mime4j.message.BinaryBody;
@@ -59,13 +59,18 @@
         return new FileInputStream(this.file);
     }
 
-    public void writeTo(final OutputStream out) throws IOException {
+    public void writeTo(final OutputStream out, int mode) throws IOException {
         if (out == null) {
             throw new IllegalArgumentException("Output stream may not be null");
         }
         InputStream in = new FileInputStream(this.file);
         try {
-            IOUtils.copy(in, out);
+            byte[] tmp = new byte[4096];
+            int l;
+            while ((l = in.read(tmp)) != -1) {
+                out.write(tmp, 0, l);
+            }
+            out.flush();
         } finally {
             in.close();
         }
@@ -75,7 +80,7 @@
         return MIME.ENC_BINARY;
     }
 
-    public Charset getCharset() {
+    public String getCharset() {
         return null;
     }
 
@@ -83,6 +88,18 @@
         return "application/octet-stream";
     }
     
+    public Map<?, ?> getContentTypeParameters() {
+        return Collections.EMPTY_MAP;
+    }
+
+    public String getMediaType() {
+        return "application";
+    }
+
+    public String getSubType() {
+        return "octet-stream";
+    }
+
     public long getContentLength() {
         return this.file.length();
     }

Modified: httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/content/InputStreamBody.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/content/InputStreamBody.java?rev=675712&r1=675711&r2=675712&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/content/InputStreamBody.java
(original)
+++ httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/content/InputStreamBody.java
Thu Jul 10 13:16:33 2008
@@ -34,9 +34,9 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.nio.charset.Charset;
+import java.util.Collections;
+import java.util.Map;
 
-import org.apache.commons.io.IOUtils;
 import org.apache.http.entity.mime.MIME;
 import org.apache.james.mime4j.message.AbstractBody;
 import org.apache.james.mime4j.message.BinaryBody;
@@ -59,12 +59,17 @@
         return this.in;
     }
 
-    public void writeTo(final OutputStream out) throws IOException {
+    public void writeTo(final OutputStream out, int mode) throws IOException {
         if (out == null) {
             throw new IllegalArgumentException("Output stream may not be null");
         }
         try {
-            IOUtils.copy(this.in, out);
+            byte[] tmp = new byte[4096];
+            int l;
+            while ((l = this.in.read(tmp)) != -1) {
+                out.write(tmp, 0, l);
+            }
+            out.flush();
         } finally {
             this.in.close();
         }
@@ -74,7 +79,7 @@
         return MIME.ENC_BINARY;
     }
 
-    public Charset getCharset() {
+    public String getCharset() {
         return null;
     }
 
@@ -82,6 +87,18 @@
         return "application/octet-stream";
     }
     
+    public Map<?, ?> getContentTypeParameters() {
+        return Collections.EMPTY_MAP;
+    }
+
+    public String getMediaType() {
+        return "application";
+    }
+
+    public String getSubType() {
+        return "octet-stream";
+    }
+
     public long getContentLength() {
         return -1;
     }

Modified: httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/content/StringBody.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/content/StringBody.java?rev=675712&r1=675711&r2=675712&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/content/StringBody.java
(original)
+++ httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/content/StringBody.java
Thu Jul 10 13:16:33 2008
@@ -33,13 +33,15 @@
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.Reader;
 import java.io.UnsupportedEncodingException;
 import java.nio.charset.Charset;
+import java.util.HashMap;
+import java.util.Map;
 
-import org.apache.commons.io.IOUtils;
 import org.apache.http.entity.mime.MIME;
 import org.apache.james.mime4j.message.AbstractBody;
 import org.apache.james.mime4j.message.TextBody;
@@ -71,25 +73,45 @@
                 this.charset);
     }
 
-    public void writeTo(final OutputStream out) throws IOException {
+    public void writeTo(final OutputStream out, int mode) throws IOException {
         if (out == null) {
             throw new IllegalArgumentException("Output stream may not be null");
         }
-        IOUtils.copy(new ByteArrayInputStream(this.content), out);
+        InputStream in = new ByteArrayInputStream(this.content);
+        byte[] tmp = new byte[4096];
+        int l;
+        while ((l = in.read(tmp)) != -1) {
+            out.write(tmp, 0, l);
+        }
+        out.flush();
     }
 
     public String getTransferEncoding() {
         return MIME.ENC_8BIT;
     }
 
-    public Charset getCharset() {
-        return this.charset;
+    public String getCharset() {
+        return this.charset.name();
     }
 
     public String getMimeType() {
         return "text/plain";
     }
     
+    public String getMediaType() {
+        return "text";
+    }
+
+    public String getSubType() {
+        return "plain";
+    }
+
+    public Map<?, ?> getContentTypeParameters() {
+        Map<Object, Object> map = new HashMap<Object, Object>();
+        map.put("charset", this.charset.name());
+        return map;
+    }
+
     public long getContentLength() {
         return this.content.length;
     }

Modified: httpcomponents/httpclient/trunk/module-httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartForm.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartForm.java?rev=675712&r1=675711&r2=675712&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartForm.java
(original)
+++ httpcomponents/httpclient/trunk/module-httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartForm.java
Thu Jul 10 13:16:33 2008
@@ -80,7 +80,7 @@
                 Field.parse("Content-Type: multipart/form-data; boundary=foo"));
         message.setHeader(header);
         
-        HttpMultipart multipart = new HttpMultipart();
+        HttpMultipart multipart = new HttpMultipart("form-data");
         multipart.setParent(message);
         BodyPart p1 = new BodyPart();
         Header h1 = new Header();
@@ -106,7 +106,7 @@
         multipart.writeTo(out);
         out.close();
         
-        String expected = "\r\n" + 
+        String expected = 
             "--foo\r\n" +
             "Content-Type: text/plain\r\n" +
             "\r\n" +
@@ -119,8 +119,7 @@
             "Content-Type: text/plain\r\n" +
             "\r\n" +
             "all kind of stuff\r\n" +
-            "--foo--\r\n" +
-            "\r\n";
+            "--foo--\r\n";
         String s = out.toString("US-ASCII");
         assertEquals(expected, s);
         assertEquals(s.length(), multipart.getTotalLength());
@@ -133,7 +132,7 @@
                 Field.parse("Content-Type: multipart/form-data; boundary=foo"));
         message.setHeader(header);
         
-        HttpMultipart multipart = new HttpMultipart();
+        HttpMultipart multipart = new HttpMultipart("form-data");
         multipart.setParent(message);
         FormBodyPart p1 = new FormBodyPart(
                 "field1",
@@ -153,7 +152,7 @@
         multipart.writeTo(out);
         out.close();
         
-        String expected = "\r\n" + 
+        String expected = 
             "--foo\r\n" +
             "Content-Disposition: form-data; name=\"field1\"\r\n" +
             "Content-Type: text/plain; charset=" + 
@@ -174,8 +173,7 @@
             "Content-Transfer-Encoding: 8bit\r\n" +
             "\r\n" +
             "all kind of stuff\r\n" +
-            "--foo--\r\n" +
-            "\r\n";
+            "--foo--\r\n";
         String s = out.toString("US-ASCII");
         assertEquals(expected, s);
         assertEquals(s.length(), multipart.getTotalLength());
@@ -197,7 +195,7 @@
             writer.close();
         }
         
-        HttpMultipart multipart = new HttpMultipart();
+        HttpMultipart multipart = new HttpMultipart("form-data");
         multipart.setParent(message);
         FormBodyPart p1 = new FormBodyPart(
                 "field1",
@@ -213,7 +211,7 @@
         multipart.writeTo(out);
         out.close();
         
-        String expected = "\r\n" + 
+        String expected =
             "--foo\r\n" +
             "Content-Disposition: form-data; name=\"field1\"; " +
                 "filename=\"" + tmpfile.getName() + "\"\r\n" +
@@ -228,8 +226,7 @@
             "Content-Transfer-Encoding: binary\r\n" +
             "\r\n" +
             "some random whatever\r\n" +
-            "--foo--\r\n" +
-            "\r\n";
+            "--foo--\r\n";
         String s = out.toString("US-ASCII");
         assertEquals(expected, s);
         assertEquals(-1, multipart.getTotalLength());
@@ -253,7 +250,7 @@
             writer.close();
         }
         
-        HttpMultipart multipart = new HttpMultipart();
+        HttpMultipart multipart = new HttpMultipart("form-data");
         multipart.setParent(message);
         FormBodyPart p1 = new FormBodyPart(
                 "field1",
@@ -271,7 +268,7 @@
         multipart.writeTo(out);
         out.close();
         
-        String expected = "\r\n" + 
+        String expected = 
             "--foo\r\n" +
             "Content-Disposition: form-data; name=\"field1\"; " +
                 "filename=\"" + tmpfile.getName() + "\"\r\n" +
@@ -282,8 +279,7 @@
                 "filename=\"file.tmp\"\r\n" +
             "\r\n" +
             "some random whatever\r\n" +
-            "--foo--\r\n" +
-            "\r\n";
+            "--foo--\r\n";
         String s = out.toString("US-ASCII");
         assertEquals(expected, s);
         assertEquals(-1, multipart.getTotalLength());
@@ -329,7 +325,7 @@
             writer.close();
         }
         
-        HttpMultipart multipart = new HttpMultipart();
+        HttpMultipart multipart = new HttpMultipart("form-data");
         multipart.setParent(message);
         FormBodyPart p1 = new FormBodyPart(
                 "field1",
@@ -347,7 +343,7 @@
         multipart.writeTo(out);
         out.close();
         
-        String expected = "\r\n" + 
+        String expected = 
             "--foo\r\n" +
             "Content-Disposition: form-data; name=\"field1\"; " +
                 "filename=\"" + s1 + ".tmp\"\r\n" +
@@ -358,8 +354,7 @@
                 "filename=\"" + s2 + ".tmp\"\r\n" +
             "\r\n" +
             "some random whatever\r\n" +
-            "--foo--\r\n" +
-            "\r\n";
+            "--foo--\r\n";
         String s = out.toString("UTF-8");
         assertEquals(expected, s);
         assertEquals(-1, multipart.getTotalLength());
@@ -377,7 +372,7 @@
                 Field.parse("Content-Type: multipart/form-data; boundary=foo"));
         message.setHeader(header);
         
-        HttpMultipart multipart = new HttpMultipart();
+        HttpMultipart multipart = new HttpMultipart("form-data");
         multipart.setParent(message);
         FormBodyPart p1 = new FormBodyPart(
                 "field1",
@@ -395,7 +390,7 @@
         
         ByteArrayOutputStream out2 = new ByteArrayOutputStream();
 
-        out2.write(("\r\n" + 
+        out2.write(( 
             "--foo\r\n" +
             "Content-Disposition: form-data; name=\"field1\"\r\n" +
             "Content-Type: text/plain; charset=ISO-8859-1\r\n" +
@@ -410,8 +405,7 @@
             "\r\n").getBytes("US-ASCII"));
         out2.write(s2.getBytes("KOI8-R"));
         out2.write(("\r\n" +
-            "--foo--\r\n" +
-            "\r\n").getBytes("US-ASCII"));
+            "--foo--\r\n").getBytes("US-ASCII"));
         out2.close();
 
         byte[] actual = out1.toByteArray();

Modified: httpcomponents/httpclient/trunk/pom.xml
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/pom.xml?rev=675712&r1=675711&r2=675712&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/pom.xml (original)
+++ httpcomponents/httpclient/trunk/pom.xml Thu Jul 10 13:16:33 2008
@@ -74,7 +74,7 @@
     <commons-logging.version>1.1.1</commons-logging.version>
     <commons-codec.version>1.3</commons-codec.version>
     <commons-io.version>1.2</commons-io.version>
-    <mime4j.version>0.3</mime4j.version>
+    <mime4j.version>0.4-SNAPSHOT</mime4j.version>
     <junit.version>3.8.2</junit.version>
   </properties>
 



Mime
View raw message