Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.HttpConnectionManager


  public void closeCommunicationLink()
  {
    if (getClient() != null)
    {
      HttpConnectionManager mgr = getClient().getHttpConnectionManager();
      if (mgr instanceof ThreadLocalHttpConnectionManager)
      {
        ((ThreadLocalHttpConnectionManager) mgr).releaseLocalConnection();
      }
    }
View Full Code Here


  /**
   * Shutdown hook that closes the underlying {@link HttpConnectionManager}'s
   * connection pool, if any.
   */
  public void destroy() {
    HttpConnectionManager connectionManager = getHttpClient().getHttpConnectionManager();
    if (connectionManager instanceof MultiThreadedHttpConnectionManager) {
      ((MultiThreadedHttpConnectionManager) connectionManager).shutdown();
    }
  }
View Full Code Here

     * held open. This is an optional method, and callers are not expected to
     * call it, but can if they want to explicitly release any open resources.
     * Once a client has been shutdown, it cannot be used to make more requests.
     */
    public void shutdown() {
        HttpConnectionManager connectionManager = httpClient.getHttpConnectionManager();
        if (connectionManager instanceof MultiThreadedHttpConnectionManager) {
            ((MultiThreadedHttpConnectionManager)connectionManager).shutdown();
        }
    }
View Full Code Here

     * held open. This is an optional method, and callers are not expected to
     * call it, but can if they want to explicitly release any open resources.
     * Once a client has been shutdown, it cannot be used to make more requests.
     */
    public void shutdown() {
        HttpConnectionManager connectionManager = httpClient.getHttpConnectionManager();
        if (connectionManager instanceof MultiThreadedHttpConnectionManager) {
            ((MultiThreadedHttpConnectionManager)connectionManager).shutdown();
        }
    }
View Full Code Here

     * held open. This is an optional method, and callers are not expected to
     * call it, but can if they want to explicitly release any open resources.
     * Once a client has been shutdown, it cannot be used to make more requests.
     */
    public void shutdown() {
        HttpConnectionManager connectionManager = httpClient.getHttpConnectionManager();
        if (connectionManager instanceof MultiThreadedHttpConnectionManager) {
            ((MultiThreadedHttpConnectionManager)connectionManager).shutdown();
        }
    }
View Full Code Here

                {
                  // Too many redirects. Something bad happened.
                  throw new RedirectException("Too many redirects");
                }
               
                    HttpConnectionManager newConnMgr = null;
               
                if (statusCode == 301) {
                  // Moved permanently, so notify the locator
                        notifyRedirect(executeURI, redirectURI);                       
                } else if (statusCode == 305) {
View Full Code Here

     * held open. This is an optional method, and callers are not expected to
     * call it, but can if they want to explicitly release any open resources.
     * Once a client has been shutdown, it cannot be used to make more requests.
     */
    public void shutdown() {
        HttpConnectionManager connectionManager = httpClient.getHttpConnectionManager();
        if (connectionManager instanceof MultiThreadedHttpConnectionManager) {
            ((MultiThreadedHttpConnectionManager)connectionManager).shutdown();
        }
    }
View Full Code Here

        // Prepare authorization header
        String authorization = "admin" + ":" + "admin";
        authorizationHeader = "Basic " + new String(Base64.encodeBase64(authorization.getBytes()));

        // Create an HTTP client
        HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
        connectionManager.getParams().setDefaultMaxConnectionsPerHost(10);
        connectionManager.getParams().setConnectionTimeout(60000);
        httpClient = new HttpClient(connectionManager);
    }
View Full Code Here

                HttpConnectionManagerParams params = new HttpConnectionManagerParams();
                params.setSoTimeout(CONNECTION_TIMEOUT);
                params.setConnectionTimeout(CONNECTION_TIMEOUT);
                // TODO: make the http client a well behaved http client, no more than x connections
                // per server (x admin configurable maybe), persistent connections and so on
                HttpConnectionManager manager = new SimpleHttpConnectionManager();
                manager.setParams(params);
                client.setHttpConnectionManager(manager);

                // prepare either a GET or a POST request
                if (ref.getMethod() == null || ref.getMethod() == MethodType.GET_LITERAL) {
                    GetMethod get = new GetMethod(ref.getHref());
View Full Code Here

    }

    public void init() throws HttpException, IOException {
        HostConfiguration hostConfig = new HostConfiguration();
        // hostConfig.setHost("www.somehost.com");
        HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
        HttpConnectionManagerParams params = new HttpConnectionManagerParams();
        int maxHostConnections = 20;
        params.setMaxConnectionsPerHost(hostConfig, maxHostConnections);
        connectionManager.setParams(params);
        httpclient = new HttpClient(connectionManager);
        Credentials creds = new UsernamePasswordCredentials(userName, password);
        httpclient.getState().setCredentials(AuthScope.ANY, creds);
        httpclient.setHostConfiguration(hostConfig);
View Full Code Here

TOP

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

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.