public HttpClient build ( ) { HttpClient httpClient = new HttpClient ( ) ; if ( proxyHost != null ) { ProxyHost h ; if ( proxyPort == - 1 ) { h = new ProxyHost ( proxyHost ) ; } else { h = new ProxyHost ( proxyHost , proxyPort ) ; } httpClient . getHostConfiguration ( ) . setProxyHost ( h ) ; } if ( basicAuthUsername != null ) { httpClient . getParams ( ) . setAuthenticationPreemptive ( authenticationPreemprive ) ; AuthScope authscope = new AuthScope ( basicAuthHost == null ? AuthScope . ANY_HOST : basicAuthHost , basicAuthPort == - 1 ? AuthScope . ANY_PORT : basicAuthPort ) ; Credentials credentials = new UsernamePasswordCredentials ( basicAuthUsername , basicAuthPassword ) ; httpClient . getState ( ) . setCredentials ( authscope , credentials ) ; } if ( sslHostConfig != null ) { sslHostConfigs . put ( secureHost , sslHostConfig ) ; } for ( Entry < String , SslHostConfig > entry : sslHostConfigs . entrySet ( ) ) { String host = entry . getKey ( ) ; SslHostConfig config = entry . getValue ( ) ; AuthSSLProtocolSocketFactory factory = new AuthSSLProtocolSocketFactory ( config . keyStoreUrl , config . keyStorePassword , config . trustKeyStoreUrl , config . trustKeyStorePassword ) ; if ( sslEnabledProtocols != null ) { factory . setEnabledProtocols ( sslEnabledProtocols ) ; } Protocol protocol = createProtocol ( factory , config ) ; httpClient . getHostConfiguration ( ) . setHost ( host , config . securePort , protocol ) ; } httpClient . getParams ( ) . setSoTimeout ( soTimeout ) ; httpClient . getParams ( ) . setConnectionManagerTimeout ( connectionManagerTimeout ) ; httpClient . getHttpConnectionManager ( ) . getParams ( ) . setConnectionTimeout ( connectionTimeout ) ; return httpClient ; }
Builds the configured HttpClient .