in src/main/java/org/apache/maven/doxia/linkcheck/validation/OnlineHTTPLinkValidator.java [251:311]
private void initHttpClient()
{
LOG.debug( "Creating a new HttpClient instance." );
HttpClientBuilder builder = HttpClients.custom();
// connection manager
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
connectionManager.setMaxTotal( 100 );
connectionManager.setDefaultMaxPerRoute( 10 );
builder.setConnectionManager( connectionManager );
RequestConfig.Builder requestConfigBuilder = RequestConfig.custom();
// redirects
requestConfigBuilder.setRedirectsEnabled( this.http.isFollowRedirects() );
// timeouts
SocketConfig.Builder socketConfigBuilder = SocketConfig.custom();
if ( this.http.getTimeout() != 0 )
{
requestConfigBuilder.setConnectTimeout( this.http.getTimeout() );
requestConfigBuilder.setSocketTimeout( this.http.getTimeout() );
socketConfigBuilder.setSoTimeout( this.http.getTimeout() );
}
builder.setDefaultRequestConfig( requestConfigBuilder.build() );
builder.setDefaultSocketConfig( socketConfigBuilder.build() );
// proxy
if ( StringUtils.isNotBlank( this.http.getProxyHost() ) )
{
HttpHost proxy = new HttpHost( this.http.getProxyHost(), this.http.getProxyPort() );
requestConfigBuilder.setProxy( proxy );
LOG.debug( "Proxy Host:" + this.http.getProxyHost() );
LOG.debug( "Proxy Port:" + this.http.getProxyPort() );
if ( StringUtils.isNotEmpty( this.http.getProxyUser() ) && this.http.getProxyPassword() != null )
{
LOG.debug( "Proxy User:" + this.http.getProxyUser() );
Credentials credentials;
if ( StringUtils.isNotEmpty( this.http.getProxyNtlmHost() ) )
{
credentials = new NTCredentials( this.http.getProxyUser(), this.http.getProxyPassword(),
this.http.getProxyNtlmHost(), this.http.getProxyNtlmDomain() );
}
else
{
credentials =
new UsernamePasswordCredentials( this.http.getProxyUser(), this.http.getProxyPassword() );
}
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials( AuthScope.ANY, credentials );
builder.setDefaultCredentialsProvider( credentialsProvider );
}
}
this.cl = builder.build();
LOG.debug( "New HttpClient instance created." );
}