hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yves ERB (JIRA)" <j...@apache.org>
Subject [jira] [Created] (HTTPASYNC-118) HttpAsyncClients.createSystem() won't use a SystemDefaultCredentialsProvider
Date Wed, 22 Feb 2017 10:57:44 GMT
Yves ERB created HTTPASYNC-118:
----------------------------------

             Summary: HttpAsyncClients.createSystem() won't use a SystemDefaultCredentialsProvider
                 Key: HTTPASYNC-118
                 URL: https://issues.apache.org/jira/browse/HTTPASYNC-118
             Project: HttpComponents HttpAsyncClient
          Issue Type: Improvement
    Affects Versions: 4.1.2
            Reporter: Yves ERB
            Priority: Minor


My HTTP proxy needs authentication.
First I setup my proxy :

{code:borderStyle=solid}
System.setProperty("http.proxyHost", host);
System.setProperty("http.proxyPort", String.valueOf(port));
System.setProperty("https.proxyHost", host);
System.setProperty("https.proxyPort", String.valueOf(port));
System.setProperty("http.nonProxyHosts", exclusions);
System.setProperty("https.nonProxyHosts", exclusions);
Authenticator.setDefault(new ProxyAuthenticator(user, password));
{code}
Nothing particular here.

When I create an HttpClient like this:
{code:borderStyle=solid}
HttpClients.createSystem();
{code}
or
{code:borderStyle=solid}
HttpClientBuilder.create.useSystemProperties().build();
{code}
The client is able to use my proxy. However, when I create an HttpAsyncClient like this :
{code:borderStyle=solid}
HttpAsyncClients.createSystem();
{code}
or
{code:borderStyle=solid}
HttpAsyncClientBuilder.create().useSystemProperties().build();
{code}
The async client gets a 407.
It's due to different default settings.

In HttpClientBuilder:
{code:borderStyle=solid}
CredentialsProvider defaultCredentialsProvider = this.credentialsProvider;
if (defaultCredentialsProvider == null) {
    if (systemProperties) {
        defaultCredentialsProvider = new SystemDefaultCredentialsProvider();
    } else {
        defaultCredentialsProvider = new BasicCredentialsProvider();
    }
}
{code}
In HttpAsyncClientBuilder:
{code:borderStyle=solid}
CredentialsProvider defaultCredentialsProvider = this.credentialsProvider;
if (defaultCredentialsProvider == null) {
    defaultCredentialsProvider = new BasicCredentialsProvider();
}
{code}
I can fix the async client with this code :
{code:borderStyle=solid}
HttpAsyncClientBuilder.create().useSystemProperties()
    .setDefaultCredentialsProvider(new SystemDefaultCredentialsProvider())
    .build();
{code}
However it would be nice to have consistent builders.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message