Android DefaultHttpRequestRetryHandler - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android DefaultHttpRequestRetryHandler class.

This code example shows how to use the following methods:getRetryCount, retryRequest
    @Test 
    public void noRetryOnConnectTimeout() throws Exception { 
        HttpContext context = mock(HttpContext.class);
        HttpUriRequest request = mock(HttpUriRequest.class);
 
        DefaultHttpRequestRetryHandler retryHandler = new DefaultHttpRequestRetryHandler();
        Assert.assertEquals(3, retryHandler.getRetryCount());
 
        when(request.isAborted()).thenReturn(Boolean.FALSE);
        when(context.getAttribute(ExecutionContext.HTTP_REQUEST)).thenReturn(request);
 
        Assert.assertFalse(retryHandler.retryRequest(new ConnectTimeoutException(), 1, context));
    } 
 
    @Test 
    public void noRetryOnUnknownHost() throws Exception { 
        HttpContext context = mock(HttpContext.class);
        HttpUriRequest request = mock(HttpUriRequest.class);
 
        DefaultHttpRequestRetryHandler retryHandler = new DefaultHttpRequestRetryHandler();
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
     * @throws IOException 
     */ 
    private <T> T download(URI uri, ResponseHandler<T> responseHandler, int maxRetries) throws ClientProtocolException, IOException {
    	try { 
			DefaultHttpClient client = new DefaultHttpClient();
			client.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(maxRetries, false));
			 
			HttpRequest request = new HttpGet(uri);
			 
			return client.execute((HttpUriRequest)request, responseHandler);
		} 
		catch (IOException ex) {
			throw ex;
		} 
    } 
} 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
    public void setRetryCount(int retryCount) {
        if (retryCount < 0) {
            throw new IllegalArgumentException("Invalid retry count: " + retryCount);
        } 
         
        final HttpRequestRetryHandler retryHandler = new DefaultHttpRequestRetryHandler(retryCount,
                true); 
        loginClient.setHttpRequestRetryHandler(retryHandler);
        if (delegateWasSet) {
            final DefaultHttpClient client = (DefaultHttpClient) delegate;
            client.setHttpRequestRetryHandler(retryHandler);
        } 
    } 
     
    public void setAccount(String accountName) {
        if (accountName == null) {
            throw new IllegalArgumentException("Account name is required");
        } 
        if (account != null && !account.name.equals(accountName)) {
            // reset authentication cookie since account name is different 
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
			ClientConnectionManager connManager = new ThreadSafeClientConnManager(
					httpParams, schemeRegistry);
			DefaultHttpClient tmpClient = new DefaultHttpClient(connManager,
					httpParams);
			tmpClient
					.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(
							5, false)); 
			Log.i(LOG_TAG, "HttpClient created!");
			return tmpClient;
		} catch (Exception e) {
			return new DefaultHttpClient();
		} 
	} 
 
	private final void releaseHttpClient() { 
		if (httpClient != null && httpClient.getConnectionManager() != null) {
			// If a ConnectionManager exists it will be closed 
			httpClient.getConnectionManager().shutdown();
			Log.i(LOG_TAG, "Releasing Connections");
		} 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
		HttpConnectionParams.setSocketBufferSize(params, mDeviceInfo
				.getMaxMsgSize()); 
		httpclient.setParams(params);
 
		httpclient
				.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(
						3, false)); 
		URL url = new URL(mProfile.getServerUrl());
		httpHost = new HttpHost(url.getHost(), url.getPort(), url.getProtocol());
 
		if (!TextUtils.isEmpty(mProfile.proxyName())) {
			final HttpHost proxy = new HttpHost(mProfile.proxyName(), mProfile
					.proxyPort(), url.getProtocol());
			httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,
					proxy);
		} 
	} 
 
	public IResponse post(IRequest request) throws DsException {
		IResponse returnData = null;
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
		supportedSchemes.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
		supportedSchemes.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
		final HttpParams httpParams = createHttpParams();
		final ThreadSafeClientConnManager tccm = new ThreadSafeClientConnManager(httpParams, supportedSchemes);
		DefaultHttpClient client = new DefaultHttpClient(tccm, httpParams);
		client.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(2, true));
		return client;
	} 
	 
	private HttpParams createHttpParams() {
		final HttpParams params = new BasicHttpParams();
		HttpConnectionParams.setStaleCheckingEnabled(params, false);
		HttpConnectionParams.setConnectionTimeout(params, 45000);
		HttpConnectionParams.setSoTimeout(params, 100000);
		HttpConnectionParams.setSocketBufferSize(params, 8192);
		HttpConnectionParams.setTcpNoDelay(params, true);
		HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
		HttpProtocolParams.setUseExpectContinue(params, false);
		HttpClientParams.setRedirecting(params, false);
		ConnManagerParams.setMaxTotalConnections(params, 50);
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
        // headers.add(new BasicHeader("Accept", "*/*")); 
        // headers.add(new BasicHeader("Accept-Encoding", "gzip, deflate")); 
        httpClientParams.setParameter(ClientPNames.DEFAULT_HEADERS, headers);
        //defaultHttpClient = new DefaultHttpClient(httpClientCm, httpClientParams); 
        defaultHttpClient = new DefaultHttpClient(httpClientParams);
        defaultHttpClient.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(3, false));
 
    } 
 
    private JSONObject Parse(HttpResponse response) {
 
        // catch all? 
        if (response.getStatusLine().getStatusCode() != 200) {
            return null; 
        } 
         
        JSONObject object = null;
        try { 
            object = new JSONObject(EntityUtils.toString(response.getEntity(), "UTF-8"));
        } catch (IOException e) {
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
This code example shows how to use the following methods:
			HttpProtocolParams.setUseExpectContinue(params, true);
			 
			ThreadSafeClientConnManager connectionManager = new ThreadSafeClientConnManager(params, schemeRegistry);
			 
			httpClient = new DefaultHttpClient(connectionManager, params);
			httpClient.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(3, false));
			httpClient.addRequestInterceptor(new HttpRequestInterceptor() 
			{ 
	            public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException 
	            { 
	                if (!request.containsHeader("Accept-Encoding")) 
	                { 
	                    request.addHeader("Accept-Encoding", "gzip");
	                } 
	            } 
	        }); 
			httpClient.addResponseInterceptor(new HttpResponseInterceptor() 
			{ 
	            public void process(final HttpResponse response, final HttpContext context) throws HttpException, IOException 
	            { 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
	private <T> T download(URI uri, ResponseHandler<T> responseHandler,
			int maxRetries) throws ClientProtocolException, IOException {
		try { 
			DefaultHttpClient client = new DefaultHttpClient();
			client.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(
					maxRetries, false));
 
			HttpRequest request = new HttpGet(uri);
 
			return client.execute((HttpUriRequest) request, responseHandler);
		} catch (IOException ex) {
			throw ex;
		} 
	} 
 
	/* 
	 * (non-Javadoc) 
	 *  
	 * @see 
	 * de.dan_nrw.boobleftboobright.IWallpaperManager#downloadImage(java.net 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Android DefaultHttpRequestRetryHandler Questions & Answers:

See Code Examples for Android DefaultHttpRequestRetryHandler Methods: