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

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

Introduction

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

Prototype

public void setParams(final HttpConnectionParams params) 

Source Link

Document

Assigns HttpConnectionParams HTTP protocol parameters for this method.

Usage

From source file:edu.internet2.middleware.shibboleth.idp.profile.saml2.SLOProfileHandler.java

/**
 * Creates Http connection./*from  w ww  .  j a va2 s . com*/
 *
 * @param serviceLogoutInfo
 * @param endpoint
 * @return
 * @throws URIException
 * @throws GeneralSecurityException
 * @throws IOException
 */
private HttpConnection createHttpConnection(LogoutInformation serviceLogoutInfo, Endpoint endpoint)
        throws URIException, GeneralSecurityException, IOException {

    HttpClientBuilder httpClientBuilder = new HttpClientBuilder();
    httpClientBuilder.setContentCharSet("UTF-8");
    SecureProtocolSocketFactory sf = new EasySSLProtocolSocketFactory();
    httpClientBuilder.setHttpsProtocolSocketFactory(sf);

    //build http connection
    HttpClient httpClient = httpClientBuilder.buildClient();

    HostConfiguration hostConfig = new HostConfiguration();
    URI location = new URI(endpoint.getLocation());
    hostConfig.setHost(location);

    LogoutRequestConfiguration config = (LogoutRequestConfiguration) getProfileConfiguration(
            serviceLogoutInfo.getEntityID(), getProfileId());
    if (log.isDebugEnabled()) {
        log.debug("Creating new HTTP connection with the following timeouts:");
        log.debug("Maximum waiting time for the connection pool is {}",
                config.getBackChannelConnectionPoolTimeout());
        log.debug("Timeout for connection establishment is {}", config.getBackChannelConnectionTimeout());
        log.debug("Timeout for soap response is {}", config.getBackChannelResponseTimeout());
    }
    HttpConnection httpConn = null;
    try {
        httpConn = httpClient.getHttpConnectionManager().getConnectionWithTimeout(hostConfig,
                config.getBackChannelConnectionPoolTimeout());
    } catch (ConnectionPoolTimeoutException e) {
        return null;
    }

    HttpConnectionParams params = new HttpConnectionParams();
    params.setConnectionTimeout(config.getBackChannelConnectionTimeout());
    params.setSoTimeout(config.getBackChannelResponseTimeout());
    httpConn.setParams(params);

    return httpConn;
}