Package org.apache.commons.httpclient.params

Examples of org.apache.commons.httpclient.params.HttpMethodParams


            isConfigurable = Configurable.class.isAssignableFrom(retryHandlerClass) ;
        }
    }
   
    protected void initialiseRetryHandler(HttpMethod method) throws IOException {
      HttpMethodParams params = method.getParams();
      if (retryHandlerClass != null) {
          final Object handler ;
          try {
              handler = retryHandlerClass.newInstance() ;
          } catch (final Throwable th) {
              final IOException ioe = new IOException("Failed to instantiate Retry Handler") ;
              ioe.initCause(th) ;
              throw ioe ;
          }
          if (isConfigurable) {
              final Configurable configurable = Configurable.class.cast(handler) ;
              try {
                  configurable.setConfiguration(config) ;
              } catch (final ConfigurationException ce) {
                  final IOException ioe = new IOException("Failed to configure Retry Handler") ;
                  ioe.initCause(ce) ;
                  throw ioe ;
              }
          }
          params.setParameter(HttpMethodParams.RETRY_HANDLER, handler);
      } else {
          HttpMethodRetryHandler other = (HttpMethodRetryHandler)params.getParameter(HttpMethodParams.RETRY_HANDLER);
          params.setParameter(HttpMethodParams.RETRY_HANDLER, new HttpMethodRetryHandlerWrapper(other));
      }
    }
View Full Code Here


    private void testDefaultRetryHandler(final String method)
        throws Exception
    {
        final HttpMethodBase httpMethodBase = executeTest(method, null) ;
        final HttpMethodParams params = httpMethodBase.getParams() ;
        final Object handler = params.getParameter(HttpMethodParams.RETRY_HANDLER) ;
        assertNotNull("retry handler", handler) ;
        assertEquals("handler class", AbstractHttpMethodFactory.HttpMethodRetryHandlerWrapper.class, handler.getClass()) ;
    }
View Full Code Here

    private void testRetryHandler(final String method)
        throws Exception
    {
        final Class<?> handlerClass = RetryHandler.class ;
        final HttpMethodBase httpMethodBase = executeTest(method, handlerClass.getName()) ;
        final HttpMethodParams params = httpMethodBase.getParams() ;
        final Object handler = params.getParameter(HttpMethodParams.RETRY_HANDLER) ;
        assertNotNull("retry handler", handler) ;
        assertEquals("handler class", handlerClass, handler.getClass()) ;
    }
View Full Code Here

    private void testConfigurableRetryHandler(final String method)
        throws Exception
    {
        final Class<ConfigurableRetryHandler> handlerClass = ConfigurableRetryHandler.class ;
        final HttpMethodBase httpMethodBase = executeTest(method, handlerClass.getName()) ;
        final HttpMethodParams params = httpMethodBase.getParams() ;
        final Object handler = params.getParameter(HttpMethodParams.RETRY_HANDLER) ;
        assertNotNull("retry handler", handler) ;
        assertEquals("handler class", handlerClass, handler.getClass()) ;
        final ConfigurableRetryHandler configurableRetryHandler = handlerClass.cast(handler) ;
        assertNotNull("config", configurableRetryHandler.getConfig()) ;
    }
View Full Code Here

        HttpMethod method = createMethod(exchange);
        Message in = exchange.getIn();
        String httpProtocolVersion = in.getHeader(Exchange.HTTP_PROTOCOL_VERSION, String.class);
        if (httpProtocolVersion != null) {
            // set the HTTP protocol version
            HttpMethodParams params = method.getParams();
            params.setVersion(HttpVersion.parse(httpProtocolVersion));
        }

        HeaderFilterStrategy strategy = getEndpoint().getHeaderFilterStrategy();

        // propagate headers as HTTP headers
View Full Code Here

   * @param dest the URL being requested. (Including hostname)
   */
  protected List<String> doRequest(HttpMethodBase method, String dest)
      throws IOException, HttpException {

    HttpMethodParams pars = method.getParams();
    pars.setParameter(HttpMethodParams.RETRY_HANDLER,
        (Object) new HttpMethodRetryHandler() {
          public boolean retryMethod(HttpMethod m, IOException e, int exec) {
            return !(e instanceof java.net.ConnectException)
                && (exec < MAX_RETRIES_PER_COLLECTOR);
          }
        });

    pars.setParameter(HttpMethodParams.SO_TIMEOUT, new Integer(COLLECTOR_TIMEOUT));

    method.setParams(pars);
    method.setPath(dest);

    // Send POST request
View Full Code Here

    this.base = url.toString();
    this.orig = url.toString();
    GetMethod get = new GetMethod(this.orig);
    get.setFollowRedirects(followRedirects);
    get.setRequestHeader("User-Agent", http.getUserAgent());
    HttpMethodParams params = get.getParams();
    if (http.getUseHttp11()) {
      params.setVersion(HttpVersion.HTTP_1_1);
    } else {
      params.setVersion(HttpVersion.HTTP_1_0);
    }
    params.makeLenient();
    params.setContentCharset("UTF-8");
    params.setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
    params.setBooleanParameter(HttpMethodParams.SINGLE_COOKIE_HEADER, true);
    // XXX (ab) not sure about this... the default is to retry 3 times; if
    // XXX the request body was sent the method is not retried, so there is
    // XXX little danger in retrying...
    // params.setParameter(HttpMethodParams.RETRY_HANDLER, null);
    try {
View Full Code Here

            {
                throw new TransformerException(HttpMessages.unsupportedMethod(method));
            }

            // Allow the user to set HttpMethodParams as an object on the message
            final HttpMethodParams params = (HttpMethodParams) msg.removeProperty(
                HttpConnector.HTTP_PARAMS_PROPERTY, PropertyScope.OUTBOUND);
            if (params != null)
            {
                httpMethod.setParams(params);
            }
View Full Code Here

    String version = header.getVersion();
   
    httpMethod = new GenericMethod(method);

    httpMethod.setURI(uri);
    HttpMethodParams httpParams = httpMethod.getParams();
    // default to use HTTP 1.0
    httpParams.setVersion(HttpVersion.HTTP_1_0);
    if (version.equalsIgnoreCase(HttpHeader.HTTP11)) {
      httpParams.setVersion(HttpVersion.HTTP_1_1);
    }
   
    // set various headers
    int pos = 0;
    Pattern pattern = null;
View Full Code Here

    } else {
      httpMethod = new GenericMethod(method);
    }

    httpMethod.setURI(uri);
    HttpMethodParams httpParams = httpMethod.getParams();
    // default to use HTTP 1.0
    httpParams.setVersion(HttpVersion.HTTP_1_0);
    if (version.equalsIgnoreCase(HttpHeader.HTTP11)) {
      httpParams.setVersion(HttpVersion.HTTP_1_1);
    }
   
    // set various headers
    int pos = 0;
    Pattern pattern = null;
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.params.HttpMethodParams

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.