Package org.apache.commons.httpclient.params

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


   public void connectToServer(final int connectTimeoutMillis, final int readTimeoutMillis) throws Exception {       
        ExecutorService executor = Executors.newSingleThreadExecutor();    
        Future<Boolean> future = executor.submit(new Callable<Boolean>() {
            public Boolean call() throws Exception {
                HttpClientParams params = new HttpClientParams();
                params.setIntParameter(HttpConnectionParams.CONNECTION_TIMEOUT, connectTimeoutMillis);
                params.setIntParameter(HttpConnectionParams.SO_TIMEOUT, readTimeoutMillis);
                Map<String,Object> props = new HashMap<String, Object>();
                props.put(CommonsHttpMessageSender.HTTP_CLIENT_PARAMS, params);
                _services = ClientFactory.createCoreServiceClient(_url.toString(), props);
                _session = _services.adminLogin(_user, _password);
                return Boolean.TRUE;
View Full Code Here


//                params.setMaxConnectionsPerHost(HostConfiguration.ANY_HOST_CONFIGURATION, 200);
//                etc...
//                connManager.setParams(params);

                httpClient = new HttpClient(connManager);
                HttpClientParams clientParams = new HttpClientParams();
                // Set the default timeout in case we have a connection pool starvation to 30sec
                clientParams.setConnectionManagerTimeout(30000);
                httpClient.setParams(clientParams);
                configContext.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient);
            }

            // Get the timeout values set in the runtime
View Full Code Here

      HttpState state = client.getState();
      state.setCredentials(
          new AuthScope(client.getHostConfiguration().getHost(),
              client.getHostConfiguration().getPort(), realm),
          new UsernamePasswordCredentials(user, password));
      HttpClientParams params = new HttpClientParams();
      params.setAuthenticationPreemptive(config.getValueAsBooleanOptional(
          Constants.CHAPTER_SYSTEM, mDestination.getName(),
          "AuthenticationPreemptive"));
      client.setParams(params);
    }
  }
View Full Code Here

    // TODO 20% speed up by params.setStaleCheckingEnabled(false);
    manager.setParams(params);

    // No automatic handling of cookies, we handle sesame's session cookies
    // manually
    HttpClientParams clientParams = new HttpClientParams();
    clientParams.setCookiePolicy(CookiePolicy.IGNORE_COOKIES);

    httpClient = new HttpClient(clientParams, manager);
  }
View Full Code Here

   }

   @Test
   public void test31ConnectionCleanupOnError() throws Exception
   {
      HttpClientParams params = new HttpClientParams();
      params.setSoTimeout(5000);
      params.setConnectionManagerTimeout(5000);


      MultiThreadedHttpConnectionManager cm = new
              MultiThreadedHttpConnectionManager();
      cm.setMaxConnectionsPerHost(10);
View Full Code Here

            // set up admin credentials
            Credentials defaultcreds = new UsernamePasswordCredentials("Admin", "admin");
            adminClient.getState().setCredentials(AuthScope.ANY, defaultcreds);

            // set up client parameters
            HttpClientParams clientParams = new HttpClientParams();
            clientParams.setSoTimeout(20000);
            // We need to allow circular redirects, because some templates redirect to the same location with different
            // query parameters and the check for circular redirect in HttpClient only checks the URI path without the
            // parameters.
            // Note that actual circular redirects are still aborted after following them for some fixed number of times
            clientParams.setBooleanParameter(HttpClientParams.ALLOW_CIRCULAR_REDIRECTS, true);
            adminClient.setParams(clientParams);

            // set up connections parameters
            HttpConnectionManagerParams connectionParams = new HttpConnectionManagerParams();
            connectionParams.setConnectionTimeout(30000);
View Full Code Here

    boolean result;
    TextElement textElement = (TextElement)formItem;
    OLog log = Tracing.createLoggerFor(this.getClass());
    if (StringHelper.containsNonWhitespace(textElement.getValue())) {
      HttpClient httpClient = HttpClientFactory.getHttpClientInstance();
      HttpClientParams httpClientParams = httpClient.getParams();
      httpClientParams.setConnectionManagerTimeout(2500);
      httpClient.setParams(httpClientParams);
      try {
        // Could throw IllegalArgumentException if argument is not a valid url
        // (e.g. contains whitespaces)
        HttpMethod httpMethod = new GetMethod(XING_NAME_VALIDATION_URL + textElement.getValue());
View Full Code Here

    OLog log = Tracing.createLoggerFor(this.getClass());
    if (StringHelper.containsNonWhitespace(textElement.getValue())) {
     
      // Use an HttpClient to fetch a profile information page from MSN.
      HttpClient httpClient = HttpClientFactory.getHttpClientInstance();
      HttpClientParams httpClientParams = httpClient.getParams();
      httpClientParams.setConnectionManagerTimeout(2500);
      httpClient.setParams(httpClientParams);
      HttpMethod httpMethod = new GetMethod(MSN_NAME_VALIDATION_URL);
      NameValuePair idParam = new NameValuePair(MSN_NAME_URL_PARAMETER, textElement.getValue());
      httpMethod.setQueryString(new NameValuePair[] {idParam});
      // Don't allow redirects since otherwise, we won't be able to get the correct status
View Full Code Here

    OLog log = Tracing.createLoggerFor(this.getClass());
    if (StringHelper.containsNonWhitespace(textElement.getValue())) {
     
      // Use an HttpClient to fetch a profile information page from ICQ.
      HttpClient httpClient = HttpClientFactory.getHttpClientInstance();
      HttpClientParams httpClientParams = httpClient.getParams();
      httpClientParams.setConnectionManagerTimeout(2500);
      httpClient.setParams(httpClientParams);
      HttpMethod httpMethod = new GetMethod(ICQ_NAME_VALIDATION_URL);
      NameValuePair uinParam = new NameValuePair(ICQ_NAME_URL_PARAMETER, textElement.getValue());
      httpMethod.setQueryString(new NameValuePair[] {uinParam});
      // Don't allow redirects since otherwise, we won't be able to get the HTTP 302 further down.
View Full Code Here

     *            this <code>UrlConfig</code>
     */
    private void setConnectionAuthorization(HttpClient client, URL u, AuthManager authManager) {
        HttpState state = client.getState();
        if (authManager != null) {
            HttpClientParams params = client.getParams();
            Authorization auth = authManager.getAuthForURL(u);
            if (auth != null) {
                    String username = auth.getUser();
                    String realm = auth.getRealm();
                    String domain = auth.getDomain();
                    if (log.isDebugEnabled()){
                        log.debug(username + " >  D="+ username + " D="+domain+" R="+realm);
                    }
                    state.setCredentials(
                            new AuthScope(u.getHost(),u.getPort(),
                                    realm.length()==0 ? null : realm //"" is not the same as no realm
                                    ,AuthScope.ANY_SCHEME),
                            // NT Includes other types of Credentials
                            new NTCredentials(
                                    username,
                                    auth.getPass(),
                                    localHost,
                                    domain
                            ));
                    // We have credentials - should we set pre-emptive authentication?
                    if (canSetPreEmptive){
                        log.debug("Setting Pre-emptive authentication");
                        params.setAuthenticationPreemptive(true);
                    }
            } else {
                state.clearCredentials();
                if (canSetPreEmptive){
                    params.setAuthenticationPreemptive(false);
                }
            }
        } else {
            state.clearCredentials();
        }
View Full Code Here

TOP

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

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.