summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sca-java-2.x/trunk/modules/host-http/META-INF/MANIFEST.MF1
-rw-r--r--sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/client/HttpClientFactory.java24
2 files changed, 15 insertions, 10 deletions
diff --git a/sca-java-2.x/trunk/modules/host-http/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/host-http/META-INF/MANIFEST.MF
index c4ccda2499..2621509ce4 100644
--- a/sca-java-2.x/trunk/modules/host-http/META-INF/MANIFEST.MF
+++ b/sca-java-2.x/trunk/modules/host-http/META-INF/MANIFEST.MF
@@ -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,
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);
}