Description: Remove hack for libhttpmime < 4.1 (fixes FTBFS).
Author: Ludovico Cavedon <cavedon@debian.org>
Forwarded: non-needed

Index: htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java
===================================================================
--- htmlunit.orig/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java	2011-11-19 20:17:28.706864002 -0800
+++ htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java	2011-11-19 20:20:38.386864000 -0800
@@ -81,8 +81,6 @@
 import org.apache.http.params.CoreConnectionPNames;
 import org.apache.http.params.HttpParams;
 import org.apache.http.protocol.HttpContext;
-import org.apache.james.mime4j.message.BodyPart;
-import org.apache.james.mime4j.parser.Field;
 import org.apache.james.mime4j.util.CharsetUtil;
 
 import com.gargoylesoftware.htmlunit.util.KeyDataPair;
@@ -250,7 +248,6 @@
                         final KeyDataPair pairWithFile = (KeyDataPair) pair;
                         final ContentBody contentBody = buildFilePart(pairWithFile, charset);
                         multipartEntity.addPart(pair.getName(), contentBody);
-                        fixBugContentType(multipartEntity, contentBody.getMimeType());
                     }
                     else {
                         final StringBody stringBody =
@@ -325,39 +322,6 @@
         return null;
     }
 
-    /**
-     * HttpClient doesn't send Content-Type header for file parts as it should.
-     * See:https://issues.apache.org/jira/browse/HTTPCLIENT-960
-     * This is a hack to fix it and it should be removed once the issue has been fixed.
-     */
-    private void fixBugContentType(final MultipartEntity multipartEntity, final String contentType) {
-        // hack!!
-        try {
-            final java.lang.reflect.Field field = MultipartEntity.class.getDeclaredField("multipart");
-            field.setAccessible(true);
-            final HttpMultipart multipart = (HttpMultipart) field.get(multipartEntity);
-            final BodyPart lastOne = multipart.getBodyParts().get(multipart.getBodyParts().size() - 1);
-            final org.apache.james.mime4j.message.Header header = lastOne.getHeader();
-            final Field cntDispHeader = header.getField(MIME.CONTENT_DISPOSITION);
-            header.removeFields(MIME.CONTENT_DISPOSITION);
-            final Field newCntDispHeader = new Field() {
-                public String getBody() {
-                    return cntDispHeader.getBody() + "\r\nContent-Type: " + contentType;
-                }
-                public String getName() {
-                    return MIME.CONTENT_DISPOSITION;
-                }
-                public org.apache.james.mime4j.util.ByteSequence getRaw() {
-                    throw new RuntimeException("No in the hack");
-                }
-            };
-            header.addField(newCntDispHeader);
-        }
-        catch (final Exception e) {
-            throw new RuntimeException("Hack to fix Content-Type submission failed", e);
-        }
-    }
-
     // FIXME Change signature ?
     ContentBody buildFilePart(final KeyDataPair pairWithFile, final String charset) throws FileNotFoundException {
         String contentType = pairWithFile.getContentType();
