Example usage for org.apache.http.params CoreConnectionPNames SO_KEEPALIVE

List of usage examples for org.apache.http.params CoreConnectionPNames SO_KEEPALIVE

Introduction

In this page you can find the example usage for org.apache.http.params CoreConnectionPNames SO_KEEPALIVE.

Prototype

String SO_KEEPALIVE

To view the source code for org.apache.http.params CoreConnectionPNames SO_KEEPALIVE.

Click Source Link

Usage

From source file:org.apache.oozie.action.callback.CallbackActionExecutor.java

private HttpClient getHttpClient() {
    CallbackActionService callbackActionService = Services.get().get(CallbackActionService.class);
    HttpClient client = new DefaultHttpClient(callbackActionService.getConnectionManager());
    client.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,
            ConfigurationService.getInt(CallbackActionExecutor.CALLBACK_ACTION_HTTP_CONNECTION_TIMEOUT_SECS)
                    * 1000);// ww w. ja v  a2  s  . co m
    client.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT,
            ConfigurationService.getInt(CallbackActionExecutor.CALLBACK_ACTION_HTTP_SOCKET_TIMEOUT_SECS)
                    * 1000);
    client.getParams().setParameter(CoreConnectionPNames.SO_KEEPALIVE,
            ConfigurationService.getInt(CallbackActionExecutor.CALLBACK_ACTION_KEEPALIVE_SECS) * 1000);
    return client;
}

From source file:org.bigmouth.nvwa.network.http.HttpClientHelper.java

@SuppressWarnings("deprecation")
private static HttpClient getHttpClient(File keystore, char[] pwd, ClientConnectionManager ccm, int port,
        int timeout) throws Exception {
    SchemeRegistry sr = ccm.getSchemeRegistry();
    KeyStore truststore = KeyStore.getInstance(KeyStore.getDefaultType());
    truststore.load(new FileInputStream(keystore), pwd);
    SSLSocketFactory socketFactory = new SSLSocketFactory(truststore);
    socketFactory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);

    sr.register(new Scheme("https", port, socketFactory));
    HttpClient httpClient = new DefaultHttpClient(ccm);
    httpClient.getParams().setParameter(CoreConnectionPNames.SO_KEEPALIVE, true);
    httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, timeout);
    httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, timeout);
    return httpClient;
}

From source file:org.bigmouth.nvwa.network.http.HttpClientHelper.java

private static HttpClient getHttpClient(SSLContext ctx, ClientConnectionManager ccm, int port, int timeout) {
    SchemeRegistry sr = ccm.getSchemeRegistry();
    sr.register(//from  w  ww .ja  v  a2  s.co  m
            new Scheme("https", port, new SSLSocketFactory(ctx, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER)));
    HttpClient httpClient = new DefaultHttpClient(ccm);
    httpClient.getParams().setParameter(CoreConnectionPNames.SO_KEEPALIVE, true);
    httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, timeout);
    httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, timeout);
    return httpClient;
}

From source file:org.bigmouth.nvwa.network.http.HttpClientHelper.java

public static HttpClient http(int timeout) {
    HttpClient httpClient = new DefaultHttpClient();
    httpClient.getParams().setParameter(CoreConnectionPNames.SO_KEEPALIVE, true);
    httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, timeout);
    httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, timeout);
    return httpClient;
}