camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmoulli...@apache.org
Subject [11/50] git commit: CAMEL-7830 RestLetHeaderFilterStrategy should filter the header of "Transfer-Encoding"
Date Fri, 17 Oct 2014 08:40:04 GMT
CAMEL-7830 RestLetHeaderFilterStrategy should filter the header of "Transfer-Encoding"

Conflicts:
	components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletSetBodyTest.java


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

Branch: refs/remotes/origin/camel-2.13.x
Commit: d1628b4bd59d5b6bb4187b0164e07026bbb065cd
Parents: aca61d1
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Wed Sep 17 10:48:41 2014 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Wed Sep 17 10:56:53 2014 +0800

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


http://git-wip-us.apache.org/repos/asf/camel/blob/d1628b4b/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/d1628b4b/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 74906ff..be12f05 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,12 @@ 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];
                 for (int i = 0; i < 10; i++) {
@@ -78,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));
             }
         };


Mime
View raw message