Example usage for org.apache.commons.httpclient HttpConnection getParams

List of usage examples for org.apache.commons.httpclient HttpConnection getParams

Introduction

In this page you can find the example usage for org.apache.commons.httpclient HttpConnection getParams.

Prototype

public HttpConnectionParams getParams() 

Source Link

Document

Returns HttpConnectionParams HTTP protocol parameters associated with this method.

Usage

From source file:com.carrotsearch.util.httpclient.SingleHttpConnectionManager.java

/** */
@Override/*from www .j av  a 2  s .com*/
public HttpConnection getConnectionWithTimeout(HostConfiguration hostConfiguration, long timeout) {
    final HttpConnection conn = new HttpConnection(hostConfiguration);
    conn.setHttpConnectionManager(this);
    conn.getParams().setDefaults(this.getParams());
    conn.getParams().setSoTimeout((int) timeout);
    return conn;
}

From source file:com.cyberway.issue.httpclient.SingleHttpConnectionManager.java

public HttpConnection getConnectionWithTimeout(HostConfiguration hostConfiguration, long timeout) {

    HttpConnection conn = new HttpConnection(hostConfiguration);
    conn.setHttpConnectionManager(this);
    conn.getParams().setDefaults(this.getParams());
    return conn;//from   w  w  w .  j  a va 2 s. c  om
}

From source file:com.cyberway.issue.httpclient.ThreadLocalHttpConnectionManager.java

/**
 * @see HttpConnectionManager#getConnectionWithTimeout(HostConfiguration, long)
 * /*from w w  w.  j  a  va 2 s.  co  m*/
 * @since 3.0
 */
public HttpConnection getConnectionWithTimeout(final HostConfiguration hostConfiguration, final long timeout) {

    final ConnectionInfo ci = getConnectionInfo();
    HttpConnection httpConnection = ci.conn;

    // make sure the host and proxy are correct for this connection
    // close it and set the values if they are not
    if (httpConnection == null || !finishLastResponse(httpConnection)
            || !hostConfiguration.hostEquals(httpConnection)
            || !hostConfiguration.proxyEquals(httpConnection)) {

        if (httpConnection != null && httpConnection.isOpen()) {
            closer.closeConnection(httpConnection);
        }

        httpConnection = new HttpConnection(hostConfiguration);
        httpConnection.setHttpConnectionManager(this);
        httpConnection.getParams().setDefaults(this.params);
        ci.conn = httpConnection;

        httpConnection.setHost(hostConfiguration.getHost());
        httpConnection.setPort(hostConfiguration.getPort());
        httpConnection.setProtocol(hostConfiguration.getProtocol());
        httpConnection.setLocalAddress(hostConfiguration.getLocalAddress());

        httpConnection.setProxyHost(hostConfiguration.getProxyHost());
        httpConnection.setProxyPort(hostConfiguration.getProxyPort());
    }

    // remove the connection from the timeout handler
    ci.idleStartTime = Long.MAX_VALUE;

    return httpConnection;
}