You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2014/05/09 11:07:18 UTC

[3/6] git commit: CAMEL-7426 camel-http4 endpoint should skip reading the form body if it is bridgeEndpoint

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/275fe569
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/275fe569
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/275fe569

Branch: refs/heads/camel-2.13.x
Commit: 275fe569ff2e79fd1364805027c9c2d227b7daf8
Parents: 55d90fa
Author: Willem Jiang <wi...@gmail.com>
Authored: Fri May 9 16:43:27 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Fri May 9 16:56:54 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/275fe569/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/275fe569/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/275fe569/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);