Repository: camel
Updated Branches:
  refs/heads/master 0068bf7e0 -> 2cf4c461c


CAMEL-7426 camel-http4 endpoint should skip reading the form body if it is 
bridgeEndpoint


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

Branch: refs/heads/master
Commit: ab97041e10898324866cbc93ad3799694cf2592b
Parents: b8b0c37
Author: Willem Jiang <willem.ji...@gmail.com>
Authored: Fri May 9 16:43:27 2014 +0800
Committer: Willem Jiang <willem.ji...@gmail.com>
Committed: Fri May 9 16:54:02 2014 +0800

----------------------------------------------------------------------
 .../java/org/apache/camel/component/http4/CamelServlet.java     | 1 +
 .../org/apache/camel/component/http4/DefaultHttpBinding.java    | 5 ++++-
 .../main/java/org/apache/camel/component/http4/HttpMessage.java | 5 +++++
 3 files changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ab97041e/components/camel-http4/src/main/java/org/apache/camel/component/http4/CamelServlet.java
----------------------------------------------------------------------
diff --git 
a/components/camel-http4/src/main/java/org/apache/camel/component/http4/CamelServlet.java
 
b/components/camel-http4/src/main/java/org/apache/camel/component/http4/CamelServlet.java
index e7e98d3..ca5de47 100644
--- 
a/components/camel-http4/src/main/java/org/apache/camel/component/http4/CamelServlet.java
+++ 
b/components/camel-http4/src/main/java/org/apache/camel/component/http4/CamelServlet.java
@@ -66,6 +66,7 @@ public class CamelServlet extends HttpServlet {
             DefaultExchange exchange = new 
DefaultExchange(consumer.getEndpoint(), ExchangePattern.InOut);
             if (consumer.getEndpoint().isBridgeEndpoint()) {
                 exchange.setProperty(Exchange.SKIP_GZIP_ENCODING, 
Boolean.TRUE);
+                exchange.setProperty(Exchange.SKIP_WWW_FORM_URLENCODED, 
Boolean.TRUE);
             }
             if (consumer.getEndpoint().isDisableStreamCache()) {
                 exchange.setProperty(Exchange.DISABLE_HTTP_STREAM_CACHE, 
Boolean.TRUE);

http://git-wip-us.apache.org/repos/asf/camel/blob/ab97041e/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
----------------------------------------------------------------------
diff --git 
a/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
 
b/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
index 6101e5b..b447558 100644
--- 
a/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
+++ 
b/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
@@ -156,8 +156,11 @@ public class DefaultHttpBinding implements HttpBinding {
                 }
             }
         }
+        Boolean flag = message.getHeader(Exchange.SKIP_WWW_FORM_URLENCODED, 
Boolean.class);
+        boolean skipWwwFormUrlEncoding =  flag != null ? flag : false; 
         if (request.getMethod().equals("POST") && request.getContentType() != 
null
-                && 
request.getContentType().startsWith(HttpConstants.CONTENT_TYPE_WWW_FORM_URLENCODED))
 {
+                && 
request.getContentType().startsWith(HttpConstants.CONTENT_TYPE_WWW_FORM_URLENCODED)
+                && !skipWwwFormUrlEncoding) {
             String charset = request.getCharacterEncoding();
             if (charset == null) {
                 charset = "UTF-8";

http://git-wip-us.apache.org/repos/asf/camel/blob/ab97041e/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpMessage.java
----------------------------------------------------------------------
diff --git 
a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpMessage.java
 
b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpMessage.java
index 34f61de..e88c171 100644
--- 
a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpMessage.java
+++ 
b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpMessage.java
@@ -41,6 +41,11 @@ public class HttpMessage extends DefaultMessage {
         this.setHeader(Exchange.HTTP_SERVLET_REQUEST, request);
         this.setHeader(Exchange.HTTP_SERVLET_RESPONSE, response);
 
+        // Check the setting of exchange
+        Boolean flag = exchange.getProperty(Exchange.SKIP_WWW_FORM_URLENCODED, 
Boolean.class);
+        if (flag != null && flag) {
+            this.setHeader(Exchange.SKIP_WWW_FORM_URLENCODED, Boolean.TRUE);
+        }
         // use binding to read the request allowing end users to use their
         // implementation of the binding
         getEndpoint().getBinding().readRequest(request, this);

Reply via email to