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;
}
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();
}
}
Aggregations