Package org.apache.http.impl.client

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


            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


        // HostConfiguration hostConfig = new HostConfiguration();
        // hostConfig.setHost("localhost");

        HttpConnectionParams.setConnectionTimeout(clientParams, DEFAULT_CONNECTION_MANAGER_TIMEOUT);
        HttpConnectionParams.setSoTimeout(clientParams, 500);
        httpClient.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(0, false));
        HttpClientParams.setCookiePolicy(clientParams, CookiePolicy.IGNORE_COOKIES);

        connectionManager.setMaxTotal(DEFAULT_MAX_CONNECTIONS);
        connectionManager.setDefaultMaxPerRoute(DEFAULT_MAX_HOST_CONNECTIONS);
        HttpConnectionParams.setStaleCheckingEnabled(clientParams, false);
View Full Code Here

                                                                                        TimeUnit.MILLISECONDS);

        DefaultHttpClient httpClient = new DefaultHttpClient(connectionManager);

        HttpParams clientParams = httpClient.getParams();
        httpClient.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(0, false));
        HttpClientParams.setCookiePolicy(clientParams, CookiePolicy.IGNORE_COOKIES);
        HttpProtocolParams.setUserAgent(clientParams, "test-agent");
        HttpProtocolParams.setVersion(clientParams, HttpVersion.HTTP_1_1);

        HttpConnectionParams.setConnectionTimeout(clientParams, 10000);
View Full Code Here

            HttpGet method = new HttpGet( url.toString() );
            // Set a user-agent that doesn't contain the word "java", otherwise it will be blocked by the W3C
            // The default user-agent is "Apache-HttpClient/4.0.2 (java 1.5)"
            method.setHeader( "user-agent", "Apache-Doxia/" + doxiaVersion() );

            HttpRequestRetryHandler retryHandler = new DefaultHttpRequestRetryHandler( 3, false );
            client.setHttpRequestRetryHandler( retryHandler );

            HttpEntity entity = null;
            try
            {
View Full Code Here

                                                  config.getConnectionTimeout(TimeUnit.MILLISECONDS));
        HttpConnectionParams.setSoTimeout(clientParams,
                                          config.getSocketTimeout(TimeUnit.MILLISECONDS));
        HttpConnectionParams.setStaleCheckingEnabled(clientParams, false);

        this.httpClient.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(0, false));
        HttpClientParams.setCookiePolicy(clientParams, CookiePolicy.IGNORE_COOKIES);

        this.reroute = config.getRoutingTier().equals(RoutingTier.SERVER);
        this.requestFormatFactory = new RequestFormatFactory();
    }
View Full Code Here

    }

    private HttpRequestRetryHandler getRetryHandler() {
        return configuration.getRetries() == 0 ? null
                : httpRequestRetryHandler != null ? httpRequestRetryHandler
                : new DefaultHttpRequestRetryHandler(configuration.getRetries(), false);
    }
View Full Code Here

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

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

    SchemeRegistry registry = new SchemeRegistry();
    registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
    registry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
    ClientConnectionManager connectionManager = new ThreadSafeClientConnManager(params, registry);
    DefaultHttpClient defaultHttpClient = new DefaultHttpClient(connectionManager, params);
    defaultHttpClient.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(0, false));
    return defaultHttpClient;
  }
View Full Code Here

   * 获取url内容.
   */
  public static String getContent(final String url) {
    final DefaultHttpClient httpClient = new DefaultHttpClient();
    final HttpUriRequest getMethod = new HttpGet(url);
    httpClient.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler());

    try {
      HttpResponse response = httpClient.execute(getMethod);
      final int statusCode = response.getStatusLine().getStatusCode();
      if (statusCode != HttpStatus.SC_OK) {
View Full Code Here

   * @return
   */
  public static boolean checkHttpStatus(final String url) {
    final DefaultHttpClient httpClient = new DefaultHttpClient();
    final HttpUriRequest getMethod = new HttpGet(url);
    httpClient.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler());
    try {
      HttpResponse response = httpClient.execute(getMethod);
      final int statusCode = response.getStatusLine().getStatusCode();
      if (statusCode == HttpStatus.SC_OK) {
        return true;
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.