You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2009/09/28 22:39:02 UTC

svn commit: r819724 - /cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java

Author: dkulp
Date: Mon Sep 28 20:39:01 2009
New Revision: 819724

URL: http://svn.apache.org/viewvc?rev=819724&view=rev
Log:
When pulling the root part out of a mime message, check if the charset
is set in the parts mime headers and use it if it is

Modified:
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java?rev=819724&r1=819723&r2=819724&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java Mon Sep 28 20:39:01 2009
@@ -34,6 +34,8 @@
 import javax.mail.MessagingException;
 import javax.mail.internet.InternetHeaders;
 
+import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.helpers.HttpHeaderHelper;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.io.CachedOutputStream;
 import org.apache.cxf.message.Attachment;
@@ -120,7 +122,15 @@
             }
 
             try {
-                message.put(InternetHeaders.class.getName(), new InternetHeaders(stream));
+                InternetHeaders ih = new InternetHeaders(stream);
+                message.put(InternetHeaders.class.getName(), ih);
+                String val = ih.getHeader("Content-Type", "; ");
+                if (!StringUtils.isEmpty(val)) {
+                    String cs = HttpHeaderHelper.findCharset(val);
+                    if (!StringUtils.isEmpty(cs)) {
+                        message.put(Message.ENCODING, HttpHeaderHelper.mapCharset(cs));
+                    }
+                }
             } catch (MessagingException e) {
                 throw new RuntimeException(e);
             }