cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r819724 - /cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
Date Mon, 28 Sep 2009 20:39:02 GMT
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);
             }



Mime
View raw message