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:16 UTC

[1/6] git commit: Clean up the unused the imports of camel-cxf

Repository: camel
Updated Branches:
  refs/heads/camel-2.12.x 32b6f773d -> 71f87b902
  refs/heads/camel-2.13.x 3827064b3 -> 63238cd98


Clean up the unused the imports of camel-cxf


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

Branch: refs/heads/camel-2.13.x
Commit: 758db0431704000c625da4414fa21601c7b67f8a
Parents: 3827064
Author: Willem Jiang <wi...@gmail.com>
Authored: Fri May 9 10:10:43 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Fri May 9 16:55:06 2014 +0800

----------------------------------------------------------------------
 .../src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java  | 2 +-
 .../java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java   | 2 --
 .../component/cxf/jaxrs/CxfRsProducerClientFactoryCache2Test.java  | 2 --
 .../apache/camel/component/cxf/jaxrs/CxfRsSpringConsumerTest.java  | 1 -
 4 files changed, 1 insertion(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/758db043/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
index bde547d..8a9ad01 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
@@ -75,7 +75,6 @@ import org.apache.cxf.databinding.source.SourceDataBinding;
 import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.endpoint.ClientImpl;
 import org.apache.cxf.endpoint.Endpoint;
-import org.apache.cxf.feature.AbstractFeature;
 import org.apache.cxf.feature.Feature;
 import org.apache.cxf.feature.LoggingFeature;
 import org.apache.cxf.frontend.ClientFactoryBean;
@@ -102,6 +101,7 @@ import org.apache.cxf.staxutils.StaxUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+
 /**
  * Defines the <a href="http://camel.apache.org/cxf.html">CXF Endpoint</a>.
  * It contains a list of properties for CXF endpoint including {@link DataFormat},

http://git-wip-us.apache.org/repos/asf/camel/blob/758db043/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
index 8c3ff1b..dec2747 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
@@ -23,7 +23,6 @@ import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Component;
@@ -31,7 +30,6 @@ import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.Service;
-import org.apache.camel.component.cxf.CxfEndpointUtils;
 import org.apache.camel.component.cxf.NullFaultListener;
 import org.apache.camel.impl.DefaultEndpoint;
 import org.apache.camel.spi.HeaderFilterStrategy;

http://git-wip-us.apache.org/repos/asf/camel/blob/758db043/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCache2Test.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCache2Test.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCache2Test.java
index a71946a..3dd6f99 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCache2Test.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCache2Test.java
@@ -26,12 +26,10 @@ import org.apache.camel.component.cxf.CXFTestSupport;
 import org.apache.camel.component.cxf.common.message.CxfConstants;
 import org.apache.camel.component.cxf.jaxrs.testbean.Customer;
 import org.apache.camel.spring.SpringCamelContext;
-import org.apache.cxf.BusFactory;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
-import org.springframework.context.ApplicationContext;
 import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 

http://git-wip-us.apache.org/repos/asf/camel/blob/758db043/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsSpringConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsSpringConsumerTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsSpringConsumerTest.java
index d149905..5a05ed0 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsSpringConsumerTest.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsSpringConsumerTest.java
@@ -28,7 +28,6 @@ import org.apache.http.HttpResponse;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.util.EntityUtils;
 import org.junit.Test;
 import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;


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

Posted by ni...@apache.org.
CAMEL-7426 camel-http 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/e7b01af0
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e7b01af0
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e7b01af0

Branch: refs/heads/camel-2.12.x
Commit: e7b01af0deda0bf642a72044cd41959e48a82338
Parents: 32b6f77
Author: Willem Jiang <wi...@gmail.com>
Authored: Fri May 9 16:38:30 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Fri May 9 16:58:10 2014 +0800

----------------------------------------------------------------------
 .../main/java/org/apache/camel/Exchange.java    |  1 +
 .../camel/component/http/CamelServlet.java      |  1 +
 .../component/http/DefaultHttpBinding.java      |  6 ++++--
 .../camel/component/http/HttpMessage.java       |  6 ++++++
 .../jetty/CamelContinuationServlet.java         |  1 +
 .../component/jetty/HttpProxyRouteTest.java     | 21 ++++++++++++++++++++
 6 files changed, 34 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/e7b01af0/camel-core/src/main/java/org/apache/camel/Exchange.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/Exchange.java b/camel-core/src/main/java/org/apache/camel/Exchange.java
index 6b909da..2c62949 100644
--- a/camel-core/src/main/java/org/apache/camel/Exchange.java
+++ b/camel-core/src/main/java/org/apache/camel/Exchange.java
@@ -178,6 +178,7 @@ public interface Exchange {
 
     String SOAP_ACTION        = "CamelSoapAction";
     String SKIP_GZIP_ENCODING = "CamelSkipGzipEncoding";
+    String SKIP_WWW_FORM_URLENCODED = "CamelSkipWwwFormUrlEncoding"; 
     String SLIP_ENDPOINT      = "CamelSlipEndpoint";
     String SPLIT_INDEX        = "CamelSplitIndex";
     String SPLIT_COMPLETE     = "CamelSplitComplete";

http://git-wip-us.apache.org/repos/asf/camel/blob/e7b01af0/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java b/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java
index a56257c..cbfded3 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java
@@ -89,6 +89,7 @@ public class CamelServlet extends HttpServlet {
 
         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/e7b01af0/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java b/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
index dd74c43..49b9a47 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
@@ -171,9 +171,11 @@ public class DefaultHttpBinding implements HttpBinding {
         }
 
         LOG.trace("HTTP method {} with Content-Type {}", request.getMethod(), request.getContentType());
-        
+        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/e7b01af0/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java
index 80a6614..8218f2d 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java
@@ -40,6 +40,12 @@ public class HttpMessage extends DefaultMessage {
         // Put the request and response into the message header
         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

http://git-wip-us.apache.org/repos/asf/camel/blob/e7b01af0/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
index de0bb8b..4f274b3 100644
--- a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
+++ b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
@@ -105,6 +105,7 @@ public class CamelContinuationServlet extends CamelServlet {
 
             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/e7b01af0/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpProxyRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpProxyRouteTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpProxyRouteTest.java
index da93bce..e0188f6 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpProxyRouteTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpProxyRouteTest.java
@@ -17,6 +17,8 @@
 package org.apache.camel.component.jetty;
 
 import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.util.StopWatch;
 import org.apache.camel.util.TimeUtils;
@@ -53,6 +55,12 @@ public class HttpProxyRouteTest extends BaseJettyTest {
         String out = template.requestBody("http://localhost:{{port}}/proxyServer", null, String.class);
         assertEquals("Get a wrong host header", "localhost:" + getPort2(), out);
     }
+    
+    @Test
+    public void testHttpProxyFormHeader() throws Exception {
+        String out = template.requestBodyAndHeader("http://localhost:{{port}}/form", "username=abc&pass=password", Exchange.CONTENT_TYPE, "application/x-www-form-urlencoded", String.class);
+        assertEquals("Get a wrong response message", "username=abc&pass=password", out);
+    }
 
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
@@ -71,6 +79,19 @@ public class HttpProxyRouteTest extends BaseJettyTest {
                     .to("http://localhost:{{port2}}/host?bridgeEndpoint=true");
                 
                 from("jetty://http://localhost:{{port2}}/host").transform(header("host"));
+                
+                // check the from request
+                from("jetty://http://localhost:{{port}}/form?bridgeEndpoint=true")
+                    .process(new Processor() {
+                        @Override
+                        public void process(Exchange exchange) throws Exception {
+                            // just take out the message body and send it back
+                            Message in = exchange.getIn();
+                            String request = in.getBody(String.class);
+                            exchange.getOut().setBody(request);
+                        }
+                        
+                    });
             }
         };
     }    


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

Posted by ni...@apache.org.
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/71f87b90
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/71f87b90
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/71f87b90

Branch: refs/heads/camel-2.12.x
Commit: 71f87b902fd123699d00e9c46cdf10339b0bcac6
Parents: e7b01af
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:58:19 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/71f87b90/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/71f87b90/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/71f87b90/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);


[4/6] git commit: CAMEL-7427 camel-netty-http endpoint should skip reading the form body if it is bridgeEndpoint

Posted by ni...@apache.org.
CAMEL-7427 camel-netty-http 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/63238cd9
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/63238cd9
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/63238cd9

Branch: refs/heads/camel-2.13.x
Commit: 63238cd986408c39905dac17c369cf3986bdb340
Parents: 275fe56
Author: Willem Jiang <wi...@gmail.com>
Authored: Fri May 9 16:45:02 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Fri May 9 16:57:02 2014 +0800

----------------------------------------------------------------------
 .../netty/http/DefaultNettyHttpBinding.java     |  4 +++-
 .../netty/http/NettyHttpComponent.java          |  1 +
 .../http/handlers/HttpServerChannelHandler.java |  1 +
 ...NettyHttpBridgeRouteUsingHttpClientTest.java | 20 ++++++++++++++++++++
 4 files changed, 25 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/63238cd9/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/DefaultNettyHttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/DefaultNettyHttpBinding.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/DefaultNettyHttpBinding.java
index 00eda1e..23cae6c 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/DefaultNettyHttpBinding.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/DefaultNettyHttpBinding.java
@@ -195,8 +195,10 @@ public class DefaultNettyHttpBinding implements NettyHttpBinding, Cloneable {
         }
 
         // if body is application/x-www-form-urlencoded then extract the body as query string and append as headers
+        // if it is a bridgeEndpoint we need to skip this part of work
         if (request.getMethod().getName().equals("POST") && request.getHeader(Exchange.CONTENT_TYPE) != null
-                && request.getHeader(Exchange.CONTENT_TYPE).startsWith(NettyHttpConstants.CONTENT_TYPE_WWW_FORM_URLENCODED)) {
+                && request.getHeader(Exchange.CONTENT_TYPE).startsWith(NettyHttpConstants.CONTENT_TYPE_WWW_FORM_URLENCODED)
+                && !configuration.isBridgeEndpoint()) {
 
             String charset = "UTF-8";
 

http://git-wip-us.apache.org/repos/asf/camel/blob/63238cd9/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
index e4142d7..07c9923 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
@@ -93,6 +93,7 @@ public class NettyHttpComponent extends NettyComponent implements HeaderFilterSt
 
         // create the address uri which includes the remainder parameters (which is not configuration parameters for this component)
         URI u = new URI(UnsafeUriCharactersEncoder.encodeHttpURI(remaining));
+        
         String addressUri = URISupport.createRemainingURI(u, parameters).toString();
 
         NettyHttpEndpoint answer = new NettyHttpEndpoint(addressUri, this, config);

http://git-wip-us.apache.org/repos/asf/camel/blob/63238cd9/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerChannelHandler.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerChannelHandler.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerChannelHandler.java
index 71a8aec..06bc81b 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerChannelHandler.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerChannelHandler.java
@@ -269,6 +269,7 @@ public class HttpServerChannelHandler extends ServerChannelHandler {
     protected void beforeProcess(Exchange exchange, MessageEvent messageEvent) {
         if (consumer.getConfiguration().isBridgeEndpoint()) {
             exchange.setProperty(Exchange.SKIP_GZIP_ENCODING, Boolean.TRUE);
+            exchange.setProperty(Exchange.SKIP_WWW_FORM_URLENCODED, Boolean.TRUE);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/63238cd9/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpBridgeRouteUsingHttpClientTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpBridgeRouteUsingHttpClientTest.java b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpBridgeRouteUsingHttpClientTest.java
index ff7958b..1dc92f5 100644
--- a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpBridgeRouteUsingHttpClientTest.java
+++ b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpBridgeRouteUsingHttpClientTest.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.netty.http;
 import java.io.ByteArrayInputStream;
 
 import org.apache.camel.Exchange;
+import org.apache.camel.Message;
 import org.apache.camel.Processor;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.builder.RouteBuilder;
@@ -45,6 +46,12 @@ public class NettyHttpBridgeRouteUsingHttpClientTest extends BaseNettyTest {
             assertTrue("We should get a RuntimeCamelException", ex instanceof RuntimeCamelException);
         }
     }
+    
+    @Test
+    public void testSendFormRequestMessage() throws Exception {
+        String out = template.requestBodyAndHeader("http://localhost:" + port2 + "/form", "username=abc&pass=password", Exchange.CONTENT_TYPE, "application/x-www-form-urlencoded", String.class);
+        assertEquals("Get a wrong response message", "username=abc&pass=password", out);
+    }
 
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
@@ -65,6 +72,19 @@ public class NettyHttpBridgeRouteUsingHttpClientTest extends BaseNettyTest {
                         .to("http://localhost:" + port1 + "?throwExceptionOnFailure=false&bridgeEndpoint=true");
 
                 from("netty-http:http://localhost:" + port1 + "?matchOnUriPrefix=true").process(serviceProc);
+                
+                // check the from request
+                from("netty-http:http://localhost:" + port2 + "/form?bridgeEndpoint=true")
+                    .process(new Processor() {
+                        @Override
+                        public void process(Exchange exchange) throws Exception {
+                            // just take out the message body and send it back
+                            Message in = exchange.getIn();
+                            String request = in.getBody(String.class);
+                            exchange.getOut().setBody(request);
+                        }
+                        
+                    });
             }
         };
     }


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

Posted by ni...@apache.org.
CAMEL-7426 camel-http 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/55d90fa4
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/55d90fa4
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/55d90fa4

Branch: refs/heads/camel-2.13.x
Commit: 55d90fa497ae38bb210018579b391e2874c8ec68
Parents: 758db04
Author: Willem Jiang <wi...@gmail.com>
Authored: Fri May 9 16:38:30 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Fri May 9 16:56:38 2014 +0800

----------------------------------------------------------------------
 .../main/java/org/apache/camel/Exchange.java    |  1 +
 .../camel/component/http/CamelServlet.java      |  1 +
 .../component/http/DefaultHttpBinding.java      |  6 ++++--
 .../camel/component/http/HttpMessage.java       |  6 ++++++
 .../jetty/CamelContinuationServlet.java         |  1 +
 .../component/jetty/HttpProxyRouteTest.java     | 21 ++++++++++++++++++++
 6 files changed, 34 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/55d90fa4/camel-core/src/main/java/org/apache/camel/Exchange.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/Exchange.java b/camel-core/src/main/java/org/apache/camel/Exchange.java
index f9f3fe3..f8c6a90 100644
--- a/camel-core/src/main/java/org/apache/camel/Exchange.java
+++ b/camel-core/src/main/java/org/apache/camel/Exchange.java
@@ -179,6 +179,7 @@ public interface Exchange {
 
     String SOAP_ACTION        = "CamelSoapAction";
     String SKIP_GZIP_ENCODING = "CamelSkipGzipEncoding";
+    String SKIP_WWW_FORM_URLENCODED = "CamelSkipWwwFormUrlEncoding"; 
     String SLIP_ENDPOINT      = "CamelSlipEndpoint";
     String SPLIT_INDEX        = "CamelSplitIndex";
     String SPLIT_COMPLETE     = "CamelSplitComplete";

http://git-wip-us.apache.org/repos/asf/camel/blob/55d90fa4/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java b/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java
index a56257c..cbfded3 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java
@@ -89,6 +89,7 @@ public class CamelServlet extends HttpServlet {
 
         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/55d90fa4/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java b/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
index dd74c43..49b9a47 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
@@ -171,9 +171,11 @@ public class DefaultHttpBinding implements HttpBinding {
         }
 
         LOG.trace("HTTP method {} with Content-Type {}", request.getMethod(), request.getContentType());
-        
+        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/55d90fa4/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java
index 80a6614..8218f2d 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java
@@ -40,6 +40,12 @@ public class HttpMessage extends DefaultMessage {
         // Put the request and response into the message header
         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

http://git-wip-us.apache.org/repos/asf/camel/blob/55d90fa4/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
index 6dc0581..7e48d2e 100644
--- a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
+++ b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
@@ -103,6 +103,7 @@ public class CamelContinuationServlet extends CamelServlet {
 
             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/55d90fa4/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpProxyRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpProxyRouteTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpProxyRouteTest.java
index da93bce..e0188f6 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpProxyRouteTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpProxyRouteTest.java
@@ -17,6 +17,8 @@
 package org.apache.camel.component.jetty;
 
 import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.util.StopWatch;
 import org.apache.camel.util.TimeUtils;
@@ -53,6 +55,12 @@ public class HttpProxyRouteTest extends BaseJettyTest {
         String out = template.requestBody("http://localhost:{{port}}/proxyServer", null, String.class);
         assertEquals("Get a wrong host header", "localhost:" + getPort2(), out);
     }
+    
+    @Test
+    public void testHttpProxyFormHeader() throws Exception {
+        String out = template.requestBodyAndHeader("http://localhost:{{port}}/form", "username=abc&pass=password", Exchange.CONTENT_TYPE, "application/x-www-form-urlencoded", String.class);
+        assertEquals("Get a wrong response message", "username=abc&pass=password", out);
+    }
 
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
@@ -71,6 +79,19 @@ public class HttpProxyRouteTest extends BaseJettyTest {
                     .to("http://localhost:{{port2}}/host?bridgeEndpoint=true");
                 
                 from("jetty://http://localhost:{{port2}}/host").transform(header("host"));
+                
+                // check the from request
+                from("jetty://http://localhost:{{port}}/form?bridgeEndpoint=true")
+                    .process(new Processor() {
+                        @Override
+                        public void process(Exchange exchange) throws Exception {
+                            // just take out the message body and send it back
+                            Message in = exchange.getIn();
+                            String request = in.getBody(String.class);
+                            exchange.getOut().setBody(request);
+                        }
+                        
+                    });
             }
         };
     }    


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

Posted by ni...@apache.org.
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);