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/08/28 08:50:25 UTC

[1/3] git commit: CAMEL-7757 Fix the EOFException in camel-restlet with thanks to Sandeep

Repository: camel
Updated Branches:
  refs/heads/master a94f95b61 -> c8c2a930b


CAMEL-7757 Fix the EOFException in camel-restlet with thanks to Sandeep


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

Branch: refs/heads/master
Commit: 866a3995002d3033cca2413142e6725900fe7b5e
Parents: 2f88e14
Author: Willem Jiang <wi...@gmail.com>
Authored: Thu Aug 28 14:31:15 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Thu Aug 28 14:49:53 2014 +0800

----------------------------------------------------------------------
 .../component/restlet/DefaultRestletBinding.java      | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/866a3995/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
index cd57867..98db3c7 100644
--- a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
+++ b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
@@ -310,13 +310,17 @@ public class DefaultRestletBinding implements RestletBinding, HeaderFilterStrate
             // get content type
             MediaType mediaType = response.getEntity().getMediaType();
             if (mediaType != null) {
+                LOG.debug("Setting the Content-Type to be {}",  mediaType.toString());
                 exchange.getOut().setHeader(Exchange.CONTENT_TYPE, mediaType.toString());
             }
-
-            // get content text
-            String text = response.getEntity().getText();
-            LOG.debug("Populate exchange from Restlet response: {}", text);
-            exchange.getOut().setBody(text);
+            if (mediaType != null && mediaType.equals(MediaType.APPLICATION_OCTET_STREAM)) {
+                exchange.getOut().setBody(response.getEntity().getStream());
+            } else {
+                // get content text
+                String text = response.getEntity().getText();
+                LOG.debug("Populate exchange from Restlet response: {}", text);
+                exchange.getOut().setBody(text);
+            }
         }
 
         // preserve headers from in by copying any non existing headers


[2/3] git commit: Fixed a CS error in camel-netty4

Posted by ni...@apache.org.
Fixed a CS error in camel-netty4


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

Branch: refs/heads/master
Commit: 2f88e14ad2a321c96b302e1e9426e24c4003e891
Parents: a94f95b
Author: Willem Jiang <wi...@gmail.com>
Authored: Thu Aug 28 14:29:47 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Thu Aug 28 14:49:53 2014 +0800

----------------------------------------------------------------------
 .../java/org/apache/camel/component/netty4/util/SubnetUtils.java | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/2f88e14a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/util/SubnetUtils.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/util/SubnetUtils.java b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/util/SubnetUtils.java
index 9edba1a..7b29995 100644
--- a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/util/SubnetUtils.java
+++ b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/util/SubnetUtils.java
@@ -219,8 +219,10 @@ public class SubnetUtils {
             if (ct == 0) {
                 return addresses;
             }
-            for (int add = low(), j = 0; add <= high(); ++add, ++j) {
+            int j = 0;
+            for (int add = low(); add <= high(); ++add) {
                 addresses[j] = format(toArray(add));
+                ++j;
             }
             return addresses;
         }


[3/3] git commit: Using HttpClient 4.3 API in camel-restlet

Posted by ni...@apache.org.
Using HttpClient 4.3 API in camel-restlet


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

Branch: refs/heads/master
Commit: c8c2a930ba44b65af853afcf788b32677e4aff68
Parents: 866a399
Author: Willem Jiang <wi...@gmail.com>
Authored: Thu Aug 28 14:49:33 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Thu Aug 28 14:49:54 2014 +0800

----------------------------------------------------------------------
 .../component/restlet/RestletRedirectTest.java  | 36 ++++++++++++--------
 .../component/restlet/RestletTestSupport.java   |  8 ++---
 2 files changed, 25 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/c8c2a930/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRedirectTest.java
----------------------------------------------------------------------
diff --git a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRedirectTest.java b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRedirectTest.java
index a54c5c1..39f366b 100644
--- a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRedirectTest.java
+++ b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRedirectTest.java
@@ -20,10 +20,10 @@ import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.http.Header;
 import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
+import org.apache.http.client.config.RequestConfig;
 import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.params.ClientPNames;
-import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
 import org.junit.Test;
 
 /**
@@ -37,19 +37,25 @@ public class RestletRedirectTest extends RestletTestSupport {
         HttpGet get = new HttpGet("http://localhost:" + portNum + "/users/homer");
 
         // do not follow redirects
-        HttpClient client = new DefaultHttpClient();
-        client.getParams().setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, false);
-
-        HttpResponse response = client.execute(get);
-
-        for (Header header : response.getAllHeaders()) {
-            log.info("Header {}", header);
+        RequestConfig requestconfig = RequestConfig.custom().setRedirectsEnabled(false).build();
+        
+        CloseableHttpClient client = HttpClientBuilder.create().setDefaultRequestConfig(requestconfig).build();
+        
+        try {
+            
+            HttpResponse response = client.execute(get);
+    
+            for (Header header : response.getAllHeaders()) {
+                log.info("Header {}", header);
+            }
+    
+            assertEquals(302, response.getStatusLine().getStatusCode());
+            assertTrue("Should have location header", response.containsHeader("Location"));
+            assertEquals("http://somewhere.com", response.getFirstHeader("Location").getValue());
+            assertEquals("bar", response.getFirstHeader("Foo").getValue());
+        } finally {
+            client.close();
         }
-
-        assertEquals(302, response.getStatusLine().getStatusCode());
-        assertTrue("Should have location header", response.containsHeader("Location"));
-        assertEquals("http://somewhere.com", response.getFirstHeader("Location").getValue());
-        assertEquals("bar", response.getFirstHeader("Foo").getValue());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/c8c2a930/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletTestSupport.java b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletTestSupport.java
index f1ddf06..389a1f5 100644
--- a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletTestSupport.java
+++ b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletTestSupport.java
@@ -22,10 +22,10 @@ import org.apache.camel.test.AvailablePortFinder;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.http.HttpResponse;
 import org.apache.http.ParseException;
-import org.apache.http.client.HttpClient;
 import org.apache.http.client.methods.HttpUriRequest;
 import org.apache.http.entity.BufferedHttpEntity;
-import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
 import org.apache.http.util.EntityUtils;
 import org.junit.BeforeClass;
 
@@ -42,13 +42,13 @@ public abstract class RestletTestSupport extends CamelTestSupport {
     }
     
     public HttpResponse doExecute(HttpUriRequest method) throws Exception {
-        HttpClient client = new DefaultHttpClient();
+        CloseableHttpClient client = HttpClientBuilder.create().build();
         try {
             HttpResponse response = client.execute(method);
             response.setEntity(new BufferedHttpEntity(response.getEntity()));
             return response;
         } finally {
-            client.getConnectionManager().shutdown();
+            client.close();
         }
     }