use of org.apache.http.conn.params.ConnPerRoute in project custom-cert-https by nelenkov.
the class MainActivity method createHttpClient.
private HttpClient createHttpClient(SocketFactory socketFactory) {
HttpParams params = new BasicHttpParams();
HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET);
HttpConnectionParams.setConnectionTimeout(params, TIMEOUT);
ConnPerRoute connPerRoute = new ConnPerRouteBean(MAX_CONN_PER_ROUTE);
ConnManagerParams.setMaxConnectionsPerRoute(params, connPerRoute);
ConnManagerParams.setMaxTotalConnections(params, MAX_CONNECTIONS);
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
SocketFactory sslSocketFactory = SSLSocketFactory.getSocketFactory();
if (socketFactory != null) {
sslSocketFactory = socketFactory;
}
schemeRegistry.register(new Scheme("https", sslSocketFactory, 443));
ClientConnectionManager cm = new ThreadSafeClientConnManager(params, schemeRegistry);
return new DefaultHttpClient(cm, params);
}
Aggregations