Search in sources :

Example 1 with SSLConnectionSocketFactoryImpl

use of com.wavefront.agent.SSLConnectionSocketFactoryImpl in project java by wavefrontHQ.

the class APIContainer method createHttpEngine.

private ClientHttpEngine createHttpEngine() {
    HttpClient httpClient = HttpClientBuilder.create().useSystemProperties().setUserAgent(proxyConfig.getHttpUserAgent()).setMaxConnTotal(proxyConfig.getHttpMaxConnTotal()).setMaxConnPerRoute(proxyConfig.getHttpMaxConnPerRoute()).setConnectionTimeToLive(1, TimeUnit.MINUTES).setDefaultSocketConfig(SocketConfig.custom().setSoTimeout(proxyConfig.getHttpRequestTimeout()).build()).setSSLSocketFactory(new SSLConnectionSocketFactoryImpl(SSLConnectionSocketFactory.getSystemSocketFactory(), proxyConfig.getHttpRequestTimeout())).setRetryHandler(new DefaultHttpRequestRetryHandler(proxyConfig.getHttpAutoRetries(), true) {

        @Override
        protected boolean handleAsIdempotent(HttpRequest request) {
            // by default, retry all http calls (submissions are idempotent).
            return true;
        }
    }).setDefaultRequestConfig(RequestConfig.custom().setContentCompressionEnabled(true).setRedirectsEnabled(true).setConnectTimeout(proxyConfig.getHttpConnectTimeout()).setConnectionRequestTimeout(proxyConfig.getHttpConnectTimeout()).setSocketTimeout(proxyConfig.getHttpRequestTimeout()).build()).build();
    final ApacheHttpClient4Engine httpEngine = new ApacheHttpClient4Engine(httpClient, true);
    // avoid using disk at all
    httpEngine.setFileUploadInMemoryThresholdLimit(100);
    httpEngine.setFileUploadMemoryUnit(ApacheHttpClient4Engine.MemoryUnit.MB);
    return httpEngine;
}
Also used : HttpRequest(org.apache.http.HttpRequest) SSLConnectionSocketFactoryImpl(com.wavefront.agent.SSLConnectionSocketFactoryImpl) HttpClient(org.apache.http.client.HttpClient) ApacheHttpClient4Engine(org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine) DefaultHttpRequestRetryHandler(org.apache.http.impl.client.DefaultHttpRequestRetryHandler)

Aggregations

SSLConnectionSocketFactoryImpl (com.wavefront.agent.SSLConnectionSocketFactoryImpl)1 HttpRequest (org.apache.http.HttpRequest)1 HttpClient (org.apache.http.client.HttpClient)1 DefaultHttpRequestRetryHandler (org.apache.http.impl.client.DefaultHttpRequestRetryHandler)1 ApacheHttpClient4Engine (org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine)1