AbstractHttpClient setHttpRequestRetryHandler - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for AbstractHttpClient setHttpRequestRetryHandler method.

This code example shows how to use the following methods:addRequestInterceptor, addResponseInterceptor, setHttpRequestRetryHandler
8
CodeRank
This code example shows how to use the following methods:addRequestInterceptor, addResponseInterceptor, getParams, setHttpRequestRetryHandler
        context.setHttpResponse(response);
        return context;
    } 
     
    private static DefaultHttpClient getHttpClient(HttpInvocationContext context) {
        DefaultHttpClient client = new DefaultHttpClient();
        HttpParams params = client.getParams();
        HttpConnectionParams.setConnectionTimeout(params, 30000);
        HttpConnectionParams.setSoTimeout(params, 30000);
        client.setHttpRequestRetryHandler(new HttpRequestRetryHandler() {                     
            public boolean retryRequest(IOException e, int i, HttpContext httpContext) {
                return false; 
            } 
        });   
        client.addRequestInterceptor(context);
        client.addResponseInterceptor(context);
        return client;
    } 
     
} 
7
CodeRank
This code example shows how to use the following methods:addRequestInterceptor, addResponseInterceptor, setHttpRequestRetryHandler
7
CodeRank
This code example shows how to use the following methods:addRequestInterceptor, addResponseInterceptor, setHttpRequestRetryHandler
			HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET);
			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 

6
CodeRank
This code example shows how to use the following methods:addRequestInterceptor, addResponseInterceptor, setHttpRequestRetryHandler
6
CodeRank
This code example shows how to use the following methods:getParams, setHttpRequestRetryHandler
public class SimpleHttpClient { 
 
    private DefaultHttpClient client;
 
    public SimpleHttpClient() { 
        this.client = new DefaultHttpClient(new ThreadSafeClientConnManager());
        HttpParams params = client.getParams();
        HttpConnectionParams.setConnectionTimeout(params, 30000);
        HttpConnectionParams.setSoTimeout(params, 30000);
        client.setHttpRequestRetryHandler(new HttpRequestRetryHandler() {
            public boolean retryRequest(IOException e, int i, HttpContext httpContext) {
                return false; 
            } 
        }); 
    } 
 
    /** 
     * Send a HTTP GET request to the specified URL 
     * 
     * @param url Target endpoint URL 
6
CodeRank
This code example shows how to use the following methods:getParams, setHttpRequestRetryHandler
	} 
 
	private DefaultHttpClient configureHTTPClient(
			ThreadSafeClientConnManager connManager) {
		connManager.setDefaultMaxPerRoute(1000);
		DefaultHttpClient client = new DefaultHttpClient(connManager);
		HttpParams params = client.getParams();
		HttpConnectionParams.setConnectionTimeout(params, 30000);
		HttpConnectionParams.setSoTimeout(params, 30000);
		client.setHttpRequestRetryHandler(new HttpRequestRetryHandler() {
			public boolean retryRequest(IOException e, int i,
					HttpContext httpContext) {
				return false; 
			} 
		}); 
         
        System.out.println("<Security xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" SOAP-ENV:mustUnderstand=\"1\">\n" +
                "            <UsernameToken>\n" + 
                "                <Username>yourName@t-online.de</Username>\n" + 
                "                <Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText\">yourPassword</Password>\n" + 
6
CodeRank
This code example shows how to use the following methods:execute, getConnectionManager, getParams, setHttpRequestRetryHandler
			+ "circle_party_list/"; 
	public static final String GET_FOLLOW_PARTY_LIST_URL = ROOT_URL
			+ "following_party_list/"; 
 
	public DefaultHttpClient getHttpClient() {
		DefaultHttpClient httpClient = new DefaultHttpClient();
		httpClient.getParams().setParameter(ClientPNames.COOKIE_POLICY,
				CookiePolicy.BEST_MATCH);
		httpClient.getParams().setParameter(
				CoreProtocolPNames.HTTP_CONTENT_CHARSET, HTTP.UTF_8);
		httpClient
				.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler());
		return httpClient;
	} 
 
	public HttpResponse post(String url, ArrayList<BasicNameValuePair> params,
			Map<String, File> files) {
 
		HttpClient httpClient = null;
		HttpPost httpPost = null;

6
CodeRank
This code example shows how to use the following methods:execute, getParams, setHttpRequestRetryHandler
 
	private String getContent(String url) {
		String responseBody;
 
		try { 
			DefaultHttpClient client = new DefaultHttpClient();
			 
			HttpRequestRetryHandler retryHandler = new HttpRequestRetryHandler() {
				public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {
					if (executionCount >= 5) {
						// Do not retry if over max retry count 
						return false; 
					} 
					if (exception instanceof NoHttpResponseException) {
						// Retry if the server dropped connection on us 
						return true; 
					} 
					if (exception instanceof SSLHandshakeException) {
						// Do not retry on SSL handshake exception 
						return false; 

6
CodeRank
This code example shows how to use the following methods:execute, setHttpRequestRetryHandler
     * @throws ClientProtocolException 
     * @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;
		} 
    } 
} 
6
CodeRank