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/04/09 10:43:26 UTC

[2/2] git commit: CAMEL-7355 Moving HttpPollingConsumer to use HttpClient 4.3.x API

CAMEL-7355 Moving HttpPollingConsumer to use HttpClient 4.3.x API


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

Branch: refs/heads/master
Commit: 4fa5ffcf9833281b09bff09315810436e41529b3
Parents: 504b12c
Author: Willem Jiang <wi...@gmail.com>
Authored: Wed Apr 9 16:08:50 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Wed Apr 9 16:41:58 2014 +0800

----------------------------------------------------------------------
 .../apache/camel/component/http4/HttpComponent.java   | 14 --------------
 .../camel/component/http4/HttpPollingConsumer.java    |  9 ++++++---
 .../camel/component/http4/helper/HttpHelper.java      |  2 +-
 3 files changed, 7 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/4fa5ffcf/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
index 1e80f00..5eb3ee3 100644
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
+++ b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
@@ -302,20 +302,6 @@ public class HttpComponent extends HeaderFilterStrategyComponent {
         
         return endpoint;
     }
-   
-    private static int getPort(URI uri) {
-        int port = uri.getPort();
-        if (port < 0) {
-            if ("http4".equals(uri.getScheme()) || "http".equals(uri.getScheme())) {
-                port = 80;
-            } else if ("https4".equals(uri.getScheme()) || "https".equals(uri.getScheme())) {
-                port = 443;
-            } else {
-                throw new IllegalArgumentException("Unknown scheme, cannot determine port number for uri: " + uri);
-            }
-        }
-        return port;
-    }
     
     protected Registry<ConnectionSocketFactory> createConnectionRegistry(X509HostnameVerifier x509HostnameVerifier, SSLContextParameters sslContextParams)
         throws GeneralSecurityException, IOException {

http://git-wip-us.apache.org/repos/asf/camel/blob/4fa5ffcf/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpPollingConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpPollingConsumer.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpPollingConsumer.java
index 9ecf668..3cfb8ec 100644
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpPollingConsumer.java
+++ b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpPollingConsumer.java
@@ -28,9 +28,10 @@ import org.apache.http.Header;
 import org.apache.http.HttpEntity;
 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.methods.HttpRequestBase;
-import org.apache.http.params.HttpConnectionParams;
+import org.apache.http.client.protocol.HttpClientContext;
 import org.apache.http.util.EntityUtils;
 
 /**
@@ -63,16 +64,18 @@ public class HttpPollingConsumer extends PollingConsumerSupport {
     protected Exchange doReceive(int timeout) {
         Exchange exchange = endpoint.createExchange();
         HttpRequestBase method = createMethod(exchange);
+        HttpClientContext httpClientContext = new HttpClientContext();
 
         // set optional timeout in millis
         if (timeout > 0) {
-            HttpConnectionParams.setSoTimeout(method.getParams(), timeout);
+            RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(timeout).build();
+            httpClientContext.setRequestConfig(requestConfig);
         }
 
         HttpEntity responeEntity = null;
         try {
             // execute request
-            HttpResponse response = httpClient.execute(method);
+            HttpResponse response = httpClient.execute(method, httpClientContext);
             int responseCode = response.getStatusLine().getStatusCode();
             responeEntity = response.getEntity();
             Object body = HttpHelper.readResponseBodyFromInputStream(responeEntity.getContent(), exchange);

http://git-wip-us.apache.org/repos/asf/camel/blob/4fa5ffcf/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpHelper.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpHelper.java
index 930e566..5610d6a 100644
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpHelper.java
+++ b/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpHelper.java
@@ -151,7 +151,7 @@ public final class HttpHelper {
         } else {
             CachedOutputStream cos = new CachedOutputStream(exchange);
             IOHelper.copyAndCloseInput(is, cos);
-            return cos.getStreamCache();
+            return cos.newStreamCache();
         }
     }