camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/2] git commit: CAMEL-6187: http producer should use charset from content-type as fallback. Thanks to Fried Hoeben for solution.
Date Mon, 26 Aug 2013 17:40:08 GMT
Updated Branches:
  refs/heads/camel-2.11.x a22ffb88f -> 7f149a59b
  refs/heads/master 6cc102241 -> 2f4e3aeaf


CAMEL-6187: http producer should use charset from content-type as fallback. Thanks to Fried
Hoeben for solution.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/2f4e3aea
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2f4e3aea
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2f4e3aea

Branch: refs/heads/master
Commit: 2f4e3aeafe626322c647fa3e5fb2521969ec405f
Parents: 6cc1022
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Mon Aug 26 19:39:23 2013 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Mon Aug 26 19:39:23 2013 +0200

----------------------------------------------------------------------
 .../java/org/apache/camel/component/http4/HttpProducer.java  | 8 ++++++++
 1 file changed, 8 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/2f4e3aea/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
index 00fea84..85820fa 100644
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
+++ b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
@@ -24,6 +24,7 @@ import java.io.Serializable;
 import java.io.UnsupportedEncodingException;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -422,6 +423,13 @@ public class HttpProducer extends DefaultProducer {
                         // do not fallback to use the default charset as it can influence
the request
                         // (for example application/x-www-form-urlencoded forms being sent)
                         String charset = IOHelper.getCharsetName(exchange, false);
+                        if (charset == null && contentType != null) {
+                            // okay try to get the charset from the content-type
+                            Charset cs = contentType.getCharset();
+                            if (cs != null) {
+                                charset = cs.name();
+                            }
+                        }
                         StringEntity entity = new StringEntity((String) data, charset);
                         if (contentType != null) {
                             entity.setContentType(contentType.toString());


Mime
View raw message