Search in sources :

Example 1 with ConnPerRoute

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);
}
Also used : BasicHttpParams(org.apache.http.params.BasicHttpParams) HttpParams(org.apache.http.params.HttpParams) Scheme(org.apache.http.conn.scheme.Scheme) ThreadSafeClientConnManager(org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager) SSLSocketFactory(org.apache.http.conn.ssl.SSLSocketFactory) SocketFactory(org.apache.http.conn.scheme.SocketFactory) PlainSocketFactory(org.apache.http.conn.scheme.PlainSocketFactory) SchemeRegistry(org.apache.http.conn.scheme.SchemeRegistry) ConnPerRoute(org.apache.http.conn.params.ConnPerRoute) BasicHttpParams(org.apache.http.params.BasicHttpParams) ConnPerRouteBean(org.apache.http.conn.params.ConnPerRouteBean) ClientConnectionManager(org.apache.http.conn.ClientConnectionManager) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient)

Aggregations

ClientConnectionManager (org.apache.http.conn.ClientConnectionManager)1 ConnPerRoute (org.apache.http.conn.params.ConnPerRoute)1 ConnPerRouteBean (org.apache.http.conn.params.ConnPerRouteBean)1 PlainSocketFactory (org.apache.http.conn.scheme.PlainSocketFactory)1 Scheme (org.apache.http.conn.scheme.Scheme)1 SchemeRegistry (org.apache.http.conn.scheme.SchemeRegistry)1 SocketFactory (org.apache.http.conn.scheme.SocketFactory)1 SSLSocketFactory (org.apache.http.conn.ssl.SSLSocketFactory)1 DefaultHttpClient (org.apache.http.impl.client.DefaultHttpClient)1 ThreadSafeClientConnManager (org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager)1 BasicHttpParams (org.apache.http.params.BasicHttpParams)1 HttpParams (org.apache.http.params.HttpParams)1