Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.DefaultHttpMethodRetryHandler


        hostConfig.setLocalAddress(IPAddress);
      }

      // Setup for 3 retry 
      httpMethodBase.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
          new DefaultHttpMethodRetryHandler(3, false));

      // now let's retrieve the data
      client.executeMethod(hostConfig, httpMethodBase);
     
      // Read the response body.
View Full Code Here


        connectionManager = new MultiThreadedHttpConnectionManager();

        params = new HttpClientParams();
        params.setParameter(HttpMethodParams.SINGLE_COOKIE_HEADER, Boolean.TRUE);
        params.setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
        params.setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler());

        AsyncHttpProviderConfig<?, ?> providerConfig = config.getAsyncHttpProviderConfig();
        if (providerConfig != null && ApacheAsyncHttpProvider.class.isAssignableFrom(providerConfig.getClass())) {
            configure(ApacheAsyncHttpProviderConfig.class.cast(providerConfig));
        }
View Full Code Here

        method.setRequestEntity(entity);
        boolean close = true;
        try {
            // Set the retry handler
            int retries = getConfiguration().isStreamingEnabled() ? 0 : getConfiguration().getRetryCount();
            method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(retries, true));
            // Set authentication
            if (endpoint.getBasicAuthentication() != null) {
                endpoint.getBasicAuthentication().applyCredentials( getClient() );
            }
            // Execute the HTTP method
View Full Code Here

    final M method = processor.createMethod(uri.toString());

    //retry policy
    HttpMethodParams methodParams = method.getParams();
    methodParams.setParameter(HttpMethodParams.RETRY_HANDLER,
            new DefaultHttpMethodRetryHandler(
                    retryCount, false));
    methodParams.setIntParameter(HttpConnectionParams.CONNECTION_TIMEOUT,
                                 connectTimeout);
    methodParams.setSoTimeout(socketTimeout);
    method.addRequestHeader(HEADER_USER_AGENT, SWIFT_USER_AGENT);
View Full Code Here

        if ( httpClient == null )
        {
            httpClient = new HttpClient(new SimpleHttpConnectionManager());
            httpClient.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
                    new DefaultHttpMethodRetryHandler(RETRY_COUNT, false));
            if (log.isDebugEnabled()) {
                log.debug("Created new HttpClient: @"+System.identityHashCode(httpClient));
            }
            httpClient.setHostConfiguration(hc);
            map.put(hc, httpClient);
View Full Code Here

        final MultiThreadedHttpConnectionManager multiThreadedHttpConnectionManager = new MultiThreadedHttpConnectionManager();
       
        final HttpConnectionManagerParams pars = multiThreadedHttpConnectionManager.getParams();
        pars.setConnectionTimeout(this.connectionTimeout);
        pars.setSoTimeout(this.soTimeout);
        pars.setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false));
        pars.setMaxTotalConnections(this.maxTotalConnections);
        pars.setDefaultMaxConnectionsPerHost(this.defaultMaxConnectionsPerHost);
       
        return multiThreadedHttpConnectionManager;
    }
View Full Code Here

      HttpClient httpClient = new HttpClient();
      PostMethod postMethod = new PostMethod(sUrl);
     
      //使用系统提供的默认的恢复策略
      postMethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
        new DefaultHttpMethodRetryHandler());
      postMethod.getParams().setContentCharset("gb2312");

      try
      {
    NameValuePair key = new NameValuePair("key", "Myth");
View Full Code Here

        String host = System.getProperty("http.proxyHost");
          String port = System.getProperty("http.proxyPort");
          if( host != null && port != null ) {
              httpClient.getHostConfiguration().setProxy(host, Integer.parseInt(port));
          }
      httpClient.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(1, false));
      httpClient.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, Integer.valueOf(TIMEOUT));
      httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(TIMEOUT);
      httpClient.getHttpConnectionManager().getParams().setSoTimeout(TIMEOUT);
     
      // Download first 50 results (50 = max. result size for Yahoo API)
View Full Code Here

      String host = System.getProperty("http.proxyHost");
        String port = System.getProperty("http.proxyPort");
        if( host != null && port != null ) {
            httpClient.getHostConfiguration().setProxy(host, Integer.parseInt(port));
        }
    httpClient.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(1, false));
    httpClient.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, new Integer(TIMEOUT));
    httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(TIMEOUT);
    httpClient.getHttpConnectionManager().getParams().setSoTimeout(TIMEOUT);
    }
View Full Code Here

      String host = System.getProperty("http.proxyHost");
        String port = System.getProperty("http.proxyPort");
        if( host != null && port != null ) {
            httpClient.getHostConfiguration().setProxy(host, Integer.parseInt(port));
        }
    httpClient.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(1, false));
    httpClient.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, new Integer(TIMEOUT));
    httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(TIMEOUT);
    httpClient.getHttpConnectionManager().getParams().setSoTimeout(TIMEOUT);
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.DefaultHttpMethodRetryHandler

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.