Package org.apache.http.impl.client

Examples of org.apache.http.impl.client.DefaultHttpRequestRetryHandler


      ConnRouteParams.setDefaultProxy(
          client.getParams(), new HttpHost(splits[0], Integer.parseInt(splits[1]), "http"));
    }

    // try resending the request once
    client.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(1, true));

    // Add hooks for gzip/deflate
    client.addRequestInterceptor(new HttpRequestInterceptor() {
      public void process(
          final org.apache.http.HttpRequest request,
          final HttpContext context) throws HttpException, IOException {
        if (!request.containsHeader("Accept-Encoding")) {
          request.addHeader("Accept-Encoding", "gzip, deflate");
        }
      }
    });
    client.addResponseInterceptor(new HttpResponseInterceptor() {
      public void process(
          final org.apache.http.HttpResponse response,
          final HttpContext context) throws HttpException, IOException {
        HttpEntity entity = response.getEntity();
        if (entity != null) {
          Header ceheader = entity.getContentEncoding();
          if (ceheader != null) {
            for (HeaderElement codec : ceheader.getElements()) {
              String codecname = codec.getName();
              if ("gzip".equalsIgnoreCase(codecname)) {
                response.setEntity(
                    new GzipDecompressingEntity(response.getEntity()));
                return;
              } else if ("deflate".equals(codecname)) {
                response.setEntity(new DeflateDecompressingEntity(response.getEntity()));
                return;
              }
            }
          }
        }
      }
    });
    client.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler() );

    // Disable automatic storage and sending of cookies (see SHINDIG-1382)
    client.removeRequestInterceptorByClass(RequestAddCookies.class);
    client.removeResponseInterceptorByClass(ResponseProcessCookies.class);
View Full Code Here


            HttpParams clientParams = new DefaultedHttpParams(new BasicHttpParams(), DEFAULT_HTTP_PARAMS);
           
            httpClient = new DefaultHttpClient(clientParams){
                @Override
                protected HttpRequestRetryHandler createHttpRequestRetryHandler() {
                    return new DefaultHttpRequestRetryHandler(RETRY_COUNT, false); // set retry count
                }
            };
            ((AbstractHttpClient) httpClient).addResponseInterceptor(new ResponseContentEncoding());
            ((AbstractHttpClient) httpClient).addResponseInterceptor(METRICS_SAVER); // HACK
            ((AbstractHttpClient) httpClient).addRequestInterceptor(METRICS_RESETTER);
View Full Code Here

            HttpParams clientParams = new DefaultedHttpParams(new BasicHttpParams(), DEFAULT_HTTP_PARAMS);
           
            httpClient = new DefaultHttpClient(clientParams){
                @Override
                protected HttpRequestRetryHandler createHttpRequestRetryHandler() {
                    return new DefaultHttpRequestRetryHandler(RETRY_COUNT, false); // set retry count
                }
            };
            ((AbstractHttpClient) httpClient).addResponseInterceptor(new ResponseContentEncoding());
            ((AbstractHttpClient) httpClient).addResponseInterceptor(METRICS_SAVER); // HACK
            ((AbstractHttpClient) httpClient).addRequestInterceptor(METRICS_RESETTER);
View Full Code Here

    ClientConnectionManager cm = new ThreadSafeClientConnManager(params, schemeRegistry);

    DefaultHttpClient client = new DefaultHttpClient(cm, params);

    // try resending the request once
    client.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(1, true));

    // Add hooks for gzip/deflate
    client.addRequestInterceptor(new HttpRequestInterceptor() {
      public void process(
          final org.apache.http.HttpRequest request,
          final HttpContext context) throws HttpException, IOException {
        if (!request.containsHeader("Accept-Encoding")) {
          request.addHeader("Accept-Encoding", "gzip, deflate");
        }
      }
    });
    client.addResponseInterceptor(new HttpResponseInterceptor() {
      public void process(
          final org.apache.http.HttpResponse response,
          final HttpContext context) throws HttpException, IOException {
        HttpEntity entity = response.getEntity();
        if (entity != null) {
          Header ceheader = entity.getContentEncoding();
          if (ceheader != null) {
            for (HeaderElement codec : ceheader.getElements()) {
              String codecname = codec.getName();
              if ("gzip".equalsIgnoreCase(codecname)) {
                response.setEntity(
                    new GzipDecompressingEntity(response.getEntity()));
                return;
              } else if ("deflate".equals(codecname)) {
                response.setEntity(new DeflateDecompressingEntity(response.getEntity()));
                return;
              }
            }
          }
        }
      }
    });
    client.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler() );

    // Use Java's built-in proxy logic
    ProxySelectorRoutePlanner routePlanner = new ProxySelectorRoutePlanner(
            client.getConnectionManager().getSchemeRegistry(),
            ProxySelector.getDefault());
View Full Code Here

            HttpParams clientParams = new DefaultedHttpParams(new BasicHttpParams(), DEFAULT_HTTP_PARAMS);
           
            httpClient = new DefaultHttpClient(clientParams){
                @Override
                protected HttpRequestRetryHandler createHttpRequestRetryHandler() {
                    return new DefaultHttpRequestRetryHandler(RETRY_COUNT, false) {
                        // TODO HACK to fix https://issues.apache.org/jira/browse/HTTPCLIENT-1120
                        // can hopefully be removed when 4.1.3 or 4.2 are released
                        @Override
                        public boolean retryRequest(IOException ex, int count, HttpContext ctx) {
                            Object request = ctx.getAttribute(ExecutionContext.HTTP_REQUEST);
View Full Code Here

            HttpParams clientParams = new DefaultedHttpParams(new BasicHttpParams(), DEFAULT_HTTP_PARAMS);
           
            httpClient = new DefaultHttpClient(clientParams){
                @Override
                protected HttpRequestRetryHandler createHttpRequestRetryHandler() {
                    return new DefaultHttpRequestRetryHandler(RETRY_COUNT, false) {
                        // TODO HACK to fix https://issues.apache.org/jira/browse/HTTPCLIENT-1120
                        // can hopefully be removed when 4.1.3 or 4.2 are released
                        @Override
                        public boolean retryRequest(IOException ex, int count, HttpContext ctx) {
                            Object request = ctx.getAttribute(ExecutionContext.HTTP_REQUEST);
View Full Code Here

  private final CloseableHttpClient httpClient;

  public ApacheHttpTransport() {
    this(CachingHttpClients.custom().disableRedirectHandling()
        .setRetryHandler(new DefaultHttpRequestRetryHandler(0, false))
        .setRoutePlanner(new SystemDefaultRoutePlanner(ProxySelector.getDefault()))
        .setConnectionManager(new PoolingHttpClientConnectionManager()).build());
  }
View Full Code Here

    ClientConnectionManager connectionManager =
      new ThreadSafeClientConnManager(params, schemeRegistry);

    DefaultHttpClient client = new DefaultHttpClient(connectionManager, params);
    client.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(3, false));
    return client;
  }
View Full Code Here

  }


  @Override
  protected HttpRequestRetryHandler createHttpRequestRetryHandler() {
    return new DefaultHttpRequestRetryHandler();
  }
View Full Code Here

        setSocketOperationTimeout(60000);
        setRequestTimeout(-1);
    }

    public void setRetryCount(int count) {
        httpClient.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(count, false));
    }
View Full Code Here

TOP

Related Classes of org.apache.http.impl.client.DefaultHttpRequestRetryHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.