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/09/17 05:04:52 UTC

[3/6] git commit: CAMEL-7830 RestLetHeaderFilterStrategy should filter the header of "Transfer-Encoding"

CAMEL-7830 RestLetHeaderFilterStrategy should filter the header of "Transfer-Encoding"


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

Branch: refs/heads/camel-2.14.x
Commit: 547cee013a2e69077ad910dcf336e62a4700a946
Parents: d2c0089
Author: Willem Jiang <wi...@gmail.com>
Authored: Wed Sep 17 10:48:41 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Wed Sep 17 10:53:13 2014 +0800

----------------------------------------------------------------------
 .../component/restlet/RestletHeaderFilterStrategy.java   |  5 +++++
 .../camel/component/restlet/RestletSetBodyTest.java      | 11 +++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/547cee01/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletHeaderFilterStrategy.java
----------------------------------------------------------------------
diff --git a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletHeaderFilterStrategy.java b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletHeaderFilterStrategy.java
index 3a102c5..662328c 100644
--- a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletHeaderFilterStrategy.java
+++ b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletHeaderFilterStrategy.java
@@ -37,6 +37,11 @@ public class RestletHeaderFilterStrategy extends DefaultHeaderFilterStrategy {
         // The "CamelAcceptContentType" header is not added to the outgoing HTTP 
         // headers but it will be going out as "Accept.
         getOutFilter().add(Exchange.ACCEPT_CONTENT_TYPE);
+        
+        // As we don't set the transfer_encoding protocol header for the restlet service
+        // we need to remove the transfer_encoding which could let the client wait forever
+        getOutFilter().add(Exchange.TRANSFER_ENCODING);
+        setCaseInsensitive(true);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/547cee01/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletSetBodyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletSetBodyTest.java b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletSetBodyTest.java
index 63eadd8..6ceb8b4 100644
--- a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletSetBodyTest.java
+++ b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletSetBodyTest.java
@@ -20,6 +20,7 @@ import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.AvailablePortFinder;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.impl.client.CloseableHttpClient;
@@ -32,16 +33,18 @@ import org.restlet.representation.InputRepresentation;
  * @version 
  */
 public class RestletSetBodyTest extends RestletTestSupport {
+    protected static int portNum2 =  AvailablePortFinder.getNextAvailable(4000);
 
     @Test
     public void testSetBody() throws Exception {
         String response = template.requestBody("restlet:http://0.0.0.0:" + portNum + "/stock/ORCL?restletMethod=get", null, String.class);
         assertEquals("110", response);
+       
     }
     
     @Test
     public void testSetBodyRepresentation() throws Exception {
-        HttpGet get = new HttpGet("http://0.0.0.0:" + "1234" + "/images/123");
+        HttpGet get = new HttpGet("http://0.0.0.0:" + portNum + "/images/123");
         CloseableHttpClient httpclient = HttpClientBuilder.create().build();
         InputStream is = null;
         try {
@@ -70,7 +73,11 @@ public class RestletSetBodyTest extends RestletTestSupport {
             @Override
             public void configure() throws Exception {
                 from("restlet:http://0.0.0.0:" + portNum + "/stock/{symbol}?restletMethods=get")
+                    .to("http://127.0.0.1:" + portNum2 + "/test?bridgeEndpoint=true")
+                    //.removeHeader("Transfer-Encoding")
                     .setBody().constant("110");
+                
+                from("jetty:http://0.0.0.0:" + portNum2 + "/test").setBody().constant("response is back");
 
                 // create ByteArrayRepresentation for response
                 byte[] image = new byte[10];
@@ -79,7 +86,7 @@ public class RestletSetBodyTest extends RestletTestSupport {
                 }
                 ByteArrayInputStream inputStream = new ByteArrayInputStream(image);
 
-                from("restlet:http://0.0.0.0:" + "1234" + "/images/{symbol}?restletMethods=get")
+                from("restlet:http://0.0.0.0:" + portNum + "/images/{symbol}?restletMethods=get")
                     .setBody().constant(new InputRepresentation(inputStream, MediaType.IMAGE_PNG, 10));
             }
         };