Search in sources :

Example 1 with DefaultHttpClient

use of cz.msebera.android.httpclient.impl.client.DefaultHttpClient in project android-async-http by loopj.

the class Redirect302Sample method getAsyncHttpClient.

@Override
public AsyncHttpClient getAsyncHttpClient() {
    AsyncHttpClient ahc = super.getAsyncHttpClient();
    HttpClient client = ahc.getHttpClient();
    if (client instanceof DefaultHttpClient) {
        Toast.makeText(this, String.format("redirects: %b\nrelative redirects: %b\ncircular redirects: %b", enableRedirects, enableRelativeRedirects, enableCircularRedirects), Toast.LENGTH_SHORT).show();
        ahc.setEnableRedirects(enableRedirects, enableRelativeRedirects, enableCircularRedirects);
    }
    return ahc;
}
Also used : HttpClient(cz.msebera.android.httpclient.client.HttpClient) DefaultHttpClient(cz.msebera.android.httpclient.impl.client.DefaultHttpClient) AsyncHttpClient(com.loopj.android.http.AsyncHttpClient) DefaultHttpClient(cz.msebera.android.httpclient.impl.client.DefaultHttpClient) AsyncHttpClient(com.loopj.android.http.AsyncHttpClient)

Example 2 with DefaultHttpClient

use of cz.msebera.android.httpclient.impl.client.DefaultHttpClient in project android-async-http by loopj.

the class MySSLSocketFactory method getNewHttpClient.

/**
     * Gets a DefaultHttpClient which trusts a set of certificates specified by the KeyStore
     *
     * @param keyStore custom provided KeyStore instance
     * @return DefaultHttpClient
     */
public static DefaultHttpClient getNewHttpClient(KeyStore keyStore) {
    try {
        SSLSocketFactory sf = new MySSLSocketFactory(keyStore);
        SchemeRegistry registry = new SchemeRegistry();
        registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
        registry.register(new Scheme("https", sf, 443));
        HttpParams params = new BasicHttpParams();
        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
        HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
        ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry);
        return new DefaultHttpClient(ccm, params);
    } catch (Exception e) {
        return new DefaultHttpClient();
    }
}
Also used : HttpParams(cz.msebera.android.httpclient.params.HttpParams) BasicHttpParams(cz.msebera.android.httpclient.params.BasicHttpParams) Scheme(cz.msebera.android.httpclient.conn.scheme.Scheme) ThreadSafeClientConnManager(cz.msebera.android.httpclient.impl.conn.tsccm.ThreadSafeClientConnManager) SchemeRegistry(cz.msebera.android.httpclient.conn.scheme.SchemeRegistry) SSLSocketFactory(cz.msebera.android.httpclient.conn.ssl.SSLSocketFactory) BasicHttpParams(cz.msebera.android.httpclient.params.BasicHttpParams) ClientConnectionManager(cz.msebera.android.httpclient.conn.ClientConnectionManager) DefaultHttpClient(cz.msebera.android.httpclient.impl.client.DefaultHttpClient) KeyStoreException(java.security.KeyStoreException) UnrecoverableKeyException(java.security.UnrecoverableKeyException) IOException(java.io.IOException) KeyManagementException(java.security.KeyManagementException) CertificateException(java.security.cert.CertificateException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Aggregations

DefaultHttpClient (cz.msebera.android.httpclient.impl.client.DefaultHttpClient)2 AsyncHttpClient (com.loopj.android.http.AsyncHttpClient)1 HttpClient (cz.msebera.android.httpclient.client.HttpClient)1 ClientConnectionManager (cz.msebera.android.httpclient.conn.ClientConnectionManager)1 Scheme (cz.msebera.android.httpclient.conn.scheme.Scheme)1 SchemeRegistry (cz.msebera.android.httpclient.conn.scheme.SchemeRegistry)1 SSLSocketFactory (cz.msebera.android.httpclient.conn.ssl.SSLSocketFactory)1 ThreadSafeClientConnManager (cz.msebera.android.httpclient.impl.conn.tsccm.ThreadSafeClientConnManager)1 BasicHttpParams (cz.msebera.android.httpclient.params.BasicHttpParams)1 HttpParams (cz.msebera.android.httpclient.params.HttpParams)1 IOException (java.io.IOException)1 KeyManagementException (java.security.KeyManagementException)1 KeyStoreException (java.security.KeyStoreException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 UnrecoverableKeyException (java.security.UnrecoverableKeyException)1 CertificateException (java.security.cert.CertificateException)1