Example usage for org.apache.http.impl.client DefaultHttpRequestRetryHandler getRetryCount

List of usage examples for org.apache.http.impl.client DefaultHttpRequestRetryHandler getRetryCount

Introduction

In this page you can find the example usage for org.apache.http.impl.client DefaultHttpRequestRetryHandler getRetryCount.

Prototype

public int getRetryCount() 

Source Link

Usage

From source file:com.google.api.client.http.apache.ApacheHttpTransportTest.java

private void checkDefaultHttpClient(DefaultHttpClient client) {
    HttpParams params = client.getParams();
    assertTrue(client.getConnectionManager() instanceof ThreadSafeClientConnManager);
    assertEquals(8192, params.getIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, -1));
    DefaultHttpRequestRetryHandler retryHandler = (DefaultHttpRequestRetryHandler) client
            .getHttpRequestRetryHandler();
    assertEquals(0, retryHandler.getRetryCount());
    assertFalse(retryHandler.isRequestSentRetryEnabled());
}

From source file:com.msopentech.thali.utilities.universal.HttpKeyHttpClient.java

public HttpKeyHttpClient(PublicKey serverPublicKey, KeyStore clientKeyStore, char[] clientKeyStorePassPhrase,
        Proxy proxy, HttpParams params)
        throws UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
    super(params);
    schemeRegistry = new SchemeRegistry();
    HttpKeySSLSocketFactory httpKeySSLSocketFactory = new HttpKeySSLSocketFactory(serverPublicKey,
            clientKeyStore, clientKeyStorePassPhrase);
    schemeRegistry.register((new Scheme("https", httpKeySSLSocketFactory, 443)));

    // Try to up retries to deal with how flakey the Tor Hidden Service channels seem to be.
    // Note that modern Apache would set this via a Param but that Param doesn't seem to exist
    // in Android land. This sucks because we can't be sure if the user is using the default
    // retry handler or different one. And no, comparing getHttpRequestRetryHandler() against
    // DefaultHttpRequestRetryHandler.INSTANCE doesn't work. :( In fact, INSTANCE isn't even available
    // in Android.
    if (proxy != null && this.getHttpRequestRetryHandler() instanceof DefaultHttpRequestRetryHandler) {
        DefaultHttpRequestRetryHandler currentHandler = (DefaultHttpRequestRetryHandler) this
                .getHttpRequestRetryHandler();
        if (currentHandler.getRetryCount() < torProxyRequestRetryCount) {
            this.setHttpRequestRetryHandler(
                    new DefaultHttpRequestRetryHandler(torProxyRequestRetryCount, true));
        }//from  w ww  .j  a va2s.  c  o  m
    }

    this.proxy = proxy;
}