tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r1383131 - in /tuscany/sca-java-2.x/trunk/modules/host-http: META-INF/MANIFEST.MF src/main/java/org/apache/tuscany/sca/host/http/client/HttpClientFactory.java
Date Mon, 10 Sep 2012 22:15:12 GMT
Author: rfeng
Date: Mon Sep 10 22:15:12 2012
New Revision: 1383131

URL: http://svn.apache.org/viewvc?rev=1383131&view=rev
Log:
Use the new api

Modified:
    tuscany/sca-java-2.x/trunk/modules/host-http/META-INF/MANIFEST.MF
    tuscany/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/client/HttpClientFactory.java

Modified: tuscany/sca-java-2.x/trunk/modules/host-http/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/host-http/META-INF/MANIFEST.MF?rev=1383131&r1=1383130&r2=1383131&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/host-http/META-INF/MANIFEST.MF (original)
+++ tuscany/sca-java-2.x/trunk/modules/host-http/META-INF/MANIFEST.MF Mon Sep 10 22:15:12
2012
@@ -23,6 +23,7 @@ Import-Package: javax.servlet,
  org.apache.http.conn.scheme;resolution:=optional,
  org.apache.http.conn.ssl;resolution:=optional,
  org.apache.http.impl.client;resolution:=optional,
+ org.apache.http.impl.conn;resolution:=optional,
  org.apache.http.impl.conn.tsccm;resolution:=optional,
  org.apache.http.params;resolution:=optional,
  org.apache.http.protocol;resolution:=optional,

Modified: tuscany/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/client/HttpClientFactory.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/client/HttpClientFactory.java?rev=1383131&r1=1383130&r2=1383131&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/client/HttpClientFactory.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/client/HttpClientFactory.java
Mon Sep 10 22:15:12 2012
@@ -30,6 +30,8 @@ import org.apache.http.conn.scheme.Schem
 import org.apache.http.conn.scheme.SchemeRegistry;
 import org.apache.http.conn.ssl.SSLSocketFactory;
 import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.conn.PoolingClientConnectionManager;
+import org.apache.http.impl.conn.SchemeRegistryFactory;
 import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpConnectionParams;
@@ -54,24 +56,26 @@ public class HttpClientFactory implement
 
     public HttpClient createHttpClient() {
         HttpParams defaultParameters = new BasicHttpParams();
-        //defaultParameters.setIntParameter(HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS,
10);
 
-        ConnManagerParams.setMaxTotalConnections(defaultParameters, 1024);
-        ConnPerRoute connPerRoute = new ConnPerRouteBean(256);
-        ConnManagerParams.setMaxConnectionsPerRoute(defaultParameters, connPerRoute);
-
-        HttpProtocolParams.setContentCharset(defaultParameters, HTTP.UTF_8);
+        HttpProtocolParams.setContentCharset(defaultParameters, "UTF-8");
         HttpConnectionParams.setConnectionTimeout(defaultParameters, 60000);
         HttpConnectionParams.setSoTimeout(defaultParameters, 60000);
 
         // See https://issues.apache.org/jira/browse/HTTPCLIENT-1138
-        SchemeRegistry supportedSchemes = new SchemeRegistry();
+        SchemeRegistry supportedSchemes = SchemeRegistryFactory.createSystemDefault();
         supportedSchemes.register(new Scheme(HttpHost.DEFAULT_SCHEME_NAME, 80, PlainSocketFactory.getSocketFactory()));
-        supportedSchemes.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory()));
-
-        ClientConnectionManager connectionManager =
-            new ThreadSafeClientConnManager(defaultParameters, supportedSchemes);
-
+        
+        // FIXME: By pass host name verification
+        SSLSocketFactory socketFactory = SSLSocketFactory.getSystemSocketFactory();
+        socketFactory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+        supportedSchemes.register(new Scheme("https", 443, socketFactory));
+
+        PoolingClientConnectionManager connectionManager =
+            new PoolingClientConnectionManager(supportedSchemes);
+
+        connectionManager.setDefaultMaxPerRoute(256);
+        connectionManager.setMaxTotal(1024);
+        
         return new DefaultHttpClient(connectionManager, defaultParameters);
     }
 



Mime
View raw message