Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Use the new api

git-svn-id: https://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk@1383131 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
commit 353a62ba608f26117a03eb21faf0ae3e562d1ba2 1 parent 1e40708
Raymond Feng authored
1  modules/host-http/META-INF/MANIFEST.MF
@@ -23,6 +23,7 @@ Import-Package: javax.servlet,
23 23
  org.apache.http.conn.scheme;resolution:=optional,
24 24
  org.apache.http.conn.ssl;resolution:=optional,
25 25
  org.apache.http.impl.client;resolution:=optional,
  26
+ org.apache.http.impl.conn;resolution:=optional,
26 27
  org.apache.http.impl.conn.tsccm;resolution:=optional,
27 28
  org.apache.http.params;resolution:=optional,
28 29
  org.apache.http.protocol;resolution:=optional,
24  modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/client/HttpClientFactory.java
@@ -30,6 +30,8 @@
30 30
 import org.apache.http.conn.scheme.SchemeRegistry;
31 31
 import org.apache.http.conn.ssl.SSLSocketFactory;
32 32
 import org.apache.http.impl.client.DefaultHttpClient;
  33
+import org.apache.http.impl.conn.PoolingClientConnectionManager;
  34
+import org.apache.http.impl.conn.SchemeRegistryFactory;
33 35
 import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
34 36
 import org.apache.http.params.BasicHttpParams;
35 37
 import org.apache.http.params.HttpConnectionParams;
@@ -54,24 +56,26 @@ public static HttpClientFactory getInstance(ExtensionPointRegistry registry) {
54 56
 
55 57
     public HttpClient createHttpClient() {
56 58
         HttpParams defaultParameters = new BasicHttpParams();
57  
-        //defaultParameters.setIntParameter(HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS, 10);
58 59
 
59  
-        ConnManagerParams.setMaxTotalConnections(defaultParameters, 1024);
60  
-        ConnPerRoute connPerRoute = new ConnPerRouteBean(256);
61  
-        ConnManagerParams.setMaxConnectionsPerRoute(defaultParameters, connPerRoute);
62  
-
63  
-        HttpProtocolParams.setContentCharset(defaultParameters, HTTP.UTF_8);
  60
+        HttpProtocolParams.setContentCharset(defaultParameters, "UTF-8");
64 61
         HttpConnectionParams.setConnectionTimeout(defaultParameters, 60000);
65 62
         HttpConnectionParams.setSoTimeout(defaultParameters, 60000);
66 63
 
67 64
         // See https://issues.apache.org/jira/browse/HTTPCLIENT-1138
68  
-        SchemeRegistry supportedSchemes = new SchemeRegistry();
  65
+        SchemeRegistry supportedSchemes = SchemeRegistryFactory.createSystemDefault();
69 66
         supportedSchemes.register(new Scheme(HttpHost.DEFAULT_SCHEME_NAME, 80, PlainSocketFactory.getSocketFactory()));
70  
-        supportedSchemes.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory()));
  67
+        
  68
+        // FIXME: By pass host name verification
  69
+        SSLSocketFactory socketFactory = SSLSocketFactory.getSystemSocketFactory();
  70
+        socketFactory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
  71
+        supportedSchemes.register(new Scheme("https", 443, socketFactory));
71 72
 
72  
-        ClientConnectionManager connectionManager =
73  
-            new ThreadSafeClientConnManager(defaultParameters, supportedSchemes);
  73
+        PoolingClientConnectionManager connectionManager =
  74
+            new PoolingClientConnectionManager(supportedSchemes);
74 75
 
  76
+        connectionManager.setDefaultMaxPerRoute(256);
  77
+        connectionManager.setMaxTotal(1024);
  78
+        
75 79
         return new DefaultHttpClient(connectionManager, defaultParameters);
76 80
     }
77 81
 

0 notes on commit 353a62b

Please sign in to comment.
Something went wrong with that request. Please try again.