Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.DefaultHttpMethodRetryHandler


   
    // get content from yahoo, code from http://jakarta.apache.org/commons/httpclient/tutorial.html
    HttpClient client = new HttpClient();
    GetMethod method = new GetMethod(url);
    method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
          new DefaultHttpMethodRetryHandler(3, false));
    try {
      int statusCode = client.executeMethod(method);
      if (statusCode != HttpStatus.SC_OK) {
        System.err.println("Method failed: " + method.getStatusLine());
      }
View Full Code Here


   
    // get content from yahoo, code from http://jakarta.apache.org/commons/httpclient/tutorial.html
    HttpClient client = new HttpClient();
    GetMethod method = new GetMethod(url);
    method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
          new DefaultHttpMethodRetryHandler(3, false));
    try {
      int statusCode = client.executeMethod(method);
      if (statusCode != HttpStatus.SC_OK) {
        System.err.println("Method failed: " + method.getStatusLine());
      }
View Full Code Here

        params.setVersion(HttpVersion.HTTP_1_1);
        params.setConnectionManagerClass(SimpleHttpConnectionManager.class);
        params.setCookiePolicy(CookiePolicy.DEFAULT);
        params.setHttpElementCharset("US-ASCII");
        params.setContentCharset("ISO-8859-1");
        params.setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler());
       
        ArrayList datePatterns = new ArrayList();
        datePatterns.addAll(
            Arrays.asList(
                new String[] {
View Full Code Here

    String content = "<error/>";   
    // get content from yahoo, code from http://jakarta.apache.org/commons/httpclient/tutorial.html
    HttpClient client = new HttpClient();
    GetMethod method = new GetMethod(url);
    method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
          new DefaultHttpMethodRetryHandler(3, false));
    try {
      int statusCode = client.executeMethod(method);
      if (statusCode != HttpStatus.SC_OK) {
        System.err.println("Method failed: " + method.getStatusLine());
      }
View Full Code Here

        }
        path = targetURL.getProtocol() + "://" + targetURL.getHost() + (targetURL.getPort() == -1 ? "" : ":" + targetURL.getPort()) + pathBuffer.toString() + (targetURL.getQuery() != null ? "?" + targetURL.getQuery() : "");
        // Create a get method for accessing the url.
        HttpMethodBase httpMethod = new GetMethod(path);
        // Set a default retry handler (see httpclient doc).
        httpMethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false));
        String contentCharset = httpClient.getParams().getContentCharset();
        // Get the response of the url in a string.
        httpClient.getParams().setContentCharset(contentCharset);
        return getResponse(path, renderContext, resource, chain, httpMethod, httpClient);
    }
View Full Code Here

        Protocol.registerProtocol("https", new Protocol("https", new EasySSLProtocolSocketFactory(), 443));
        httpClient.getParams().setContentCharset("UTF-8");
        // Create a post method for accessing the url.
        PostMethod postMethod = new PostMethod(path);
        // Set a default retry handler (see httpclient doc).
        postMethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false));
        if (parameters != null) {
            Iterator iterator = parameters.entrySet().iterator();
            StringBuffer buffer = new StringBuffer(4096);
            while (iterator.hasNext()) {
                Map.Entry entry = (Map.Entry) iterator.next();
View Full Code Here

                    if (!redirectLocation.startsWith("http")) {
                        URL siteURL = new URL(urlToClip);
                        String tmpURL = siteURL.getProtocol() + "://" + siteURL.getHost() + ((siteURL.getPort() > 0) ? ":" + siteURL.getPort() : "") + "/" + redirectLocation;
                        httpMethod = new GetMethod(tmpURL);
                        // Set a default retry handler (see httpclient doc).
                        httpMethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false));
                        httpMethod.getParams().setParameter("http.connection.timeout", resource.getNode().getPropertyAsString("connectionTimeout"));
                        httpMethod.getParams().setParameter("http.protocol.expect-continue", resource.getNode().getPropertyAsString("expectContinue"));
                        httpMethod.getParams().setCookiePolicy(CookiePolicy.RFC_2965);
                    } else {
                        httpMethod = new GetMethod(redirectLocation);
View Full Code Here

    private boolean isNetworkedResourceAvailable(String url) {
        HttpClient client = new HttpClient();
        GetMethod method = new GetMethod(url);
        client.getHttpConnectionManager().getParams().setConnectionTimeout(1000);
                method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
                                        new DefaultHttpMethodRetryHandler(1, false));

        try {
            int statusCode = client.executeMethod(method);
            if (statusCode != HttpStatus.SC_OK) {
                return false;
View Full Code Here

    client = new HttpClient();
    method = new PostMethod(getServiceUrl(ENGINE_INFO_SERVICE));
   
    // Provide custom retry handler is necessary
      method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
          new DefaultHttpMethodRetryHandler(3, false));

     nameValuePairs   = new NameValuePair[] {
          new NameValuePair("infoType", infoType)
      };
      
View Full Code Here

     
      log.info("[HTTP Request Cookie]"+ (String) config.getVariable().get(Constant.V_CONFIG_VARIABLE_COOKIE));
    }
    //使用系统提供的默认的恢复策略
    getMethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
        new DefaultHttpMethodRetryHandler());
    try {
       //执行getMethod
       int statusCode = httpClient.executeMethod(getMethod);
       if (statusCode != HttpStatus.SC_OK) {
         log.error("[Method failed] " + getMethod.getStatusLine());
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.