summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/host-http/src/main/java/org
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2012-09-10 22:15:12 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2012-09-10 22:15:12 +0000
commit6320f67c7cefc3e8c349676fe532098d172e2ef6 (patch)
treecddcca49e61a9ee3ad492f9fcb1f1e402f647e79 /sca-java-2.x/trunk/modules/host-http/src/main/java/org
parentca0830350cddf1b0b0e96d52b7d48f275fb14c7f (diff)
Use the new api
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1383131 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/host-http/src/main/java/org')
-rw-r--r--sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/client/HttpClientFactory.java24
1 files changed, 14 insertions, 10 deletions
diff --git a/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/client/HttpClientFactory.java b/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/client/HttpClientFactory.java
index 8c9b1f3774..35c07329bb 100644
--- a/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/client/HttpClientFactory.java
+++ b/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/client/HttpClientFactory.java
@@ -30,6 +30,8 @@ import org.apache.http.conn.scheme.Scheme;
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 implements LifeCycleListener {
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()));
+
+ // FIXME: By pass host name verification
+ SSLSocketFactory socketFactory = SSLSocketFactory.getSystemSocketFactory();
+ socketFactory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+ supportedSchemes.register(new Scheme("https", 443, socketFactory));
- ClientConnectionManager connectionManager =
- new ThreadSafeClientConnManager(defaultParameters, supportedSchemes);
+ PoolingClientConnectionManager connectionManager =
+ new PoolingClientConnectionManager(supportedSchemes);
+ connectionManager.setDefaultMaxPerRoute(256);
+ connectionManager.setMaxTotal(1024);
+
return new DefaultHttpClient(connectionManager, defaultParameters);
}