Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.HttpConnectionManager


        final ConfigurationContext configContext = msgContext.getConfigurationContext();
        synchronized (lock) {
            httpClient = (HttpClient) configContext.getProperty(HTTPConstants.CACHED_HTTP_CLIENT);
            if (httpClient == null) {
                log.trace("Making new ConnectionManager");
                HttpConnectionManager connManager = new MultiThreadedHttpConnectionManager();

                // In case we need to set any params, do it here, but for now use defaults.
//                HttpConnectionManagerParams params = new HttpConnectionManagerParams();
//                params.setMaxConnectionsPerHost(HostConfiguration.ANY_HOST_CONFIGURATION, 200);
//                etc...
View Full Code Here


        return client;
    }

    protected void closeHttpClientConnection() throws FileSystemException
    {
        HttpConnectionManager mgr = getClient().getHttpConnectionManager();
        if (mgr instanceof WebdavConnectionManager)
        {
            ((WebdavConnectionManager) mgr).releaseLocalConnection();
        }
    }
View Full Code Here

   * @param user can be NULL
   * @param password can be NULL
   * @return HttpClient
   */
  public static HttpClient getHttpClientInstance(String user, String password) {
    HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
    HttpConnectionParams params = connectionManager.getParams();
    // wait max 10 seconds to establish connection
    params.setConnectionTimeout(10000);
    // a read() call on the InputStream associated with this Socket
    // will block for only this amount
    params.setSoTimeout(10000);
View Full Code Here

                post.setRequestEntity(req);
                post.setRequestHeader("Content-type", contentType);

                HttpClient httpClient = new HttpClient();
                if (this.getTimeout() > 0) {
                    HttpConnectionManager httpManager = httpClient.getHttpConnectionManager();
                    HttpConnectionManagerParams httpParams  = new HttpConnectionManagerParams();
                    httpParams.setConnectionTimeout(this.getTimeout()*1000);
                    httpManager.setParams(httpParams);
                }
                rc = httpClient.executeMethod(post);
               
                if (outputFile != null)
                    logResponse(inputFile, outputFile, post.getResponseBodyAsStream());
View Full Code Here

    public boolean interrupt() {
        HttpClient client = savedClient;
        if (client != null) {
            savedClient = null;
            // TODO - not sure this is the best method
            final HttpConnectionManager httpConnectionManager = client.getHttpConnectionManager();
            if (httpConnectionManager instanceof SimpleHttpConnectionManager) {// Should be true
                ((SimpleHttpConnectionManager)httpConnectionManager).shutdown();
            }
        }
        return client != null;
View Full Code Here

    public synchronized void run() {
        while (!shutdown) {
            Iterator iter = connectionManagers.iterator();
           
            while (iter.hasNext()) {
                HttpConnectionManager connectionManager = (HttpConnectionManager) iter.next();
                connectionManager.closeIdleConnections(connectionTimeout);
            }
           
            try {
                this.wait(timeoutInterval);
            } catch (InterruptedException e) {
View Full Code Here

    public void close() {
        if (log.isTraceEnabled()) {
            log.trace("Closing HTTP transport to " + httpInfo);
        }

        HttpConnectionManager manager = client.getHttpConnectionManager();
        if (manager instanceof SimpleHttpConnectionManager) {
            try {
                ((SimpleHttpConnectionManager) manager).closeIdleConnections(0);
            } catch (NullPointerException npe) {
                // ignore
View Full Code Here

        HttpConnectionManagerParams connectionManagerParams = new HttpConnectionManagerParams();
        // setup the httpConnectionManagerParams
        IntrospectionSupport.setProperties(connectionManagerParams, parameters, "httpConnectionManager.");
        validateParameters(uri, parameters, "httpConnectionManager.");
        // make sure the component httpConnectionManager is take effect
        HttpConnectionManager thisHttpConnectionManager = httpConnectionManager;
        if (thisHttpConnectionManager == null) {
            // only set the params on the new created http connection manager
            thisHttpConnectionManager = new MultiThreadedHttpConnectionManager();
            thisHttpConnectionManager.setParams(connectionManagerParams);
        }
        // create the configurer to use for this endpoint (authMethods contains the used methods created by the configurer)
        final Set<AuthMethod> authMethods = new LinkedHashSet<AuthMethod>();
        HttpClientConfigurer configurer = createHttpClientConfigurer(parameters, authMethods);
        addressUri = UnsafeUriCharactersEncoder.encodeHttpURI(addressUri);
View Full Code Here

    public synchronized void run() {
        while (!shutdown) {
            Iterator iter = connectionManagers.iterator();
           
            while (iter.hasNext()) {
                HttpConnectionManager connectionManager = (HttpConnectionManager) iter.next();
                connectionManager.closeIdleConnections(connectionTimeout);
            }
           
            try {
                this.wait(timeoutInterval);
            } catch (InterruptedException e) {
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

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.