hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r705898 - in /httpcomponents/httpclient/trunk: ./ module-httpmime/src/main/java/org/apache/http/entity/mime/
Date Sat, 18 Oct 2008 17:14:05 GMT
Author: olegk
Date: Sat Oct 18 10:14:05 2008
New Revision: 705898

URL: http://svn.apache.org/viewvc?rev=705898&view=rev
Log:
Upgraded HttpCore dependency to version 4.0-beta3; upgraded Mime4j dependency to version 0.5

Added:
    httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/UnexpectedMimeException.java
  (with props)
Modified:
    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/MultipartEntity.java
    httpcomponents/httpclient/trunk/pom.xml

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=705898&r1=705897&r2=705898&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
Sat Oct 18 10:14:05 2008
@@ -32,6 +32,7 @@
 package org.apache.http.entity.mime;
 
 import org.apache.http.entity.mime.content.ContentBody;
+import org.apache.james.mime4j.MimeException;
 import org.apache.james.mime4j.descriptor.ContentDescriptor;
 import org.apache.james.mime4j.field.Field;
 import org.apache.james.mime4j.message.BodyPart;
@@ -82,7 +83,7 @@
             buffer.append(body.getFilename());
             buffer.append("\"");
         }
-        getHeader().addField(Field.parse(buffer.toString()));
+        addField(buffer.toString());
     }
     
     protected void generateContentType(final ContentDescriptor desc) {
@@ -95,7 +96,7 @@
                 buffer.append("; charset=");
                 buffer.append(desc.getCharset());
             }
-            getHeader().addField(Field.parse(buffer.toString()));
+            addField(buffer.toString());
         }
     }
     
@@ -105,8 +106,17 @@
             buffer.append(MIME.CONTENT_TRANSFER_ENC);
             buffer.append(": ");
             buffer.append(desc.getTransferEncoding());
-            getHeader().addField(Field.parse(buffer.toString()));
+            addField(buffer.toString());
         }
     }
 
+    private void addField(final String s) {
+        try {
+            getHeader().addField(Field.parse(s));
+        } catch (MimeException ex) {
+            // Should never happen
+            throw new UnexpectedMimeException(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=705898&r1=705897&r2=705898&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
Sat Oct 18 10:14:05 2008
@@ -44,6 +44,7 @@
 import org.apache.http.entity.mime.content.ContentBody;
 import org.apache.http.message.BasicHeader;
 import org.apache.http.protocol.HTTP;
+import org.apache.james.mime4j.MimeException;
 import org.apache.james.mime4j.field.Field;
 import org.apache.james.mime4j.message.Message;
 
@@ -62,6 +63,7 @@
         "-_1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
             .toCharArray();
     
+    private final Message message;
     private final HttpMultipart multipart;
     private final Header contentType;
     
@@ -79,17 +81,16 @@
                 generateContentType(boundary, charset));
         this.dirty = true;
         
-        Message message = new Message();
+        this.message = new Message();
         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);
+        this.message.setHeader(header);
         this.multipart.setParent(message);
         if (mode == null) {
             mode = HttpMultipartMode.STRICT;
         }
         this.multipart.setMode(mode);
+        addField("Content-Type: " + this.contentType.getValue());
     }
 
     public MultipartEntity(final HttpMultipartMode mode) {
@@ -179,4 +180,13 @@
         this.multipart.writeTo(outstream);
     }
 
+    private void addField(final String s) {
+        try {
+            this.message.getHeader().addField(Field.parse(s));
+        } catch (MimeException ex) {
+            // Should never happen
+            throw new UnexpectedMimeException(ex);
+        }
+    }
+    
 }

Added: httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/UnexpectedMimeException.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/UnexpectedMimeException.java?rev=705898&view=auto
==============================================================================
--- httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/UnexpectedMimeException.java
(added)
+++ httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/UnexpectedMimeException.java
Sat Oct 18 10:14:05 2008
@@ -0,0 +1,43 @@
+/*
+ * $HeadURL:$
+ * $Revision:$
+ * $Date:$
+ *
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+package org.apache.http.entity.mime;
+
+import org.apache.james.mime4j.MimeException;
+
+public class UnexpectedMimeException extends RuntimeException {
+
+    private static final long serialVersionUID = 1316818299528463579L;
+
+    public UnexpectedMimeException(MimeException ex) {
+        super(ex.getMessage(), ex);
+    }
+    
+}

Propchange: httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/UnexpectedMimeException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/UnexpectedMimeException.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: httpcomponents/httpclient/trunk/module-httpmime/src/main/java/org/apache/http/entity/mime/UnexpectedMimeException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: httpcomponents/httpclient/trunk/pom.xml
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/pom.xml?rev=705898&r1=705897&r2=705898&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/pom.xml (original)
+++ httpcomponents/httpclient/trunk/pom.xml Sat Oct 18 10:14:05 2008
@@ -70,11 +70,10 @@
   </scm>
 
   <properties>
-    <httpcore.version>4.0-beta2</httpcore.version>
+    <httpcore.version>4.0-beta3</httpcore.version>
     <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.4</mime4j.version>
+    <mime4j.version>0.5</mime4j.version>
     <junit.version>3.8.2</junit.version>
   </properties>
 



Mime
View raw message