Search in sources :

Example 1 with EasySSLSocketFactory

use of com.github.ignition.support.http.ssl.EasySSLSocketFactory in project ignition by mttkay.

the class IgnitedHttp method setupHttpClient.

protected void setupHttpClient() {
    BasicHttpParams httpParams = new BasicHttpParams();
    ConnManagerParams.setTimeout(httpParams, DEFAULT_WAIT_FOR_CONNECTION_TIMEOUT);
    ConnManagerParams.setMaxConnectionsPerRoute(httpParams, new ConnPerRouteBean(DEFAULT_MAX_CONNECTIONS));
    ConnManagerParams.setMaxTotalConnections(httpParams, DEFAULT_MAX_CONNECTIONS);
    HttpConnectionParams.setSoTimeout(httpParams, DEFAULT_SOCKET_TIMEOUT);
    HttpConnectionParams.setTcpNoDelay(httpParams, true);
    HttpProtocolParams.setVersion(httpParams, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setUserAgent(httpParams, DEFAULT_HTTP_USER_AGENT);
    SchemeRegistry schemeRegistry = new SchemeRegistry();
    schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
    if (IgnitedDiagnostics.ANDROID_API_LEVEL >= 7) {
        schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
    } else {
        // used to work around a bug in Android 1.6:
        // http://code.google.com/p/android/issues/detail?id=1946
        // TODO: is there a less rigorous workaround for this?
        schemeRegistry.register(new Scheme("https", new EasySSLSocketFactory(), 443));
    }
    ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager(httpParams, schemeRegistry);
    httpClient = new DefaultHttpClient(cm, httpParams);
}
Also used : Scheme(org.apache.http.conn.scheme.Scheme) ThreadSafeClientConnManager(org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager) SchemeRegistry(org.apache.http.conn.scheme.SchemeRegistry) EasySSLSocketFactory(com.github.ignition.support.http.ssl.EasySSLSocketFactory) BasicHttpParams(org.apache.http.params.BasicHttpParams) ConnPerRouteBean(org.apache.http.conn.params.ConnPerRouteBean) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient)

Aggregations

EasySSLSocketFactory (com.github.ignition.support.http.ssl.EasySSLSocketFactory)1 ConnPerRouteBean (org.apache.http.conn.params.ConnPerRouteBean)1 Scheme (org.apache.http.conn.scheme.Scheme)1 SchemeRegistry (org.apache.http.conn.scheme.SchemeRegistry)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