> However, here localMachineName and domainName have to be guessed somehow...

This was not your main question, but I think this can be used to get that other 
information (on Windows):

                        workstation = System.getenv("COMPUTERNAME");
                        domain = System.getenv("USERDOMAIN");

You questions look like questions I was asking a few months ago as I was trying 
to figure out how to get this all to work.  If you are working on the same 
problems I was, you may find it helpful to look at some of the questions I have 
already asked on this list:

Re: Proxy Authentication Strategy (2016-04-11)
Re: CredentialsProvider (2016-03-21)
RE: WinHttpClients (2016-03-15)

Good luck,
Mark


Disclaimer:
The opinions provided herein do not necessarily state or reflect those of 
Donnell Systems, Inc.(DSI). DSI makes no warranty for and assumes no legal 
liability or responsibility for the posting.

-----Original Message-----
From: Oleg Kalnichevski [mailto:ol...@apache.org] 
Sent: Friday, April 15, 2016 6:20 AM
To: HttpClient User Discussion
Subject: Re: HttpClientBuilder does not use system properties for proxy

On Fri, 2016-04-15 at 11:59 +0200, Philip Kahle wrote:
> Hi,
> 
> I am instantiating a HttpClientBuilder like this and tried to make it 
> use the Java system properties for a proxy server via useSystemProperties():
> 
> protected static HttpClientBuilder builder; ...
> PoolingHttpClientConnectionManager cm = new 
> PoolingHttpClientConnectionManager();
> builder =
> HttpClients.custom().setConnectionManager(cm).useSystemProperties();
> ...
> CloseableHttpClient httpClient = builder.build();
> 
> However it does not set the proxy (all hostname, port, username and 
> password have been set at this point).
> 
> I don't see how to get a SystemDefaultHttpClient at this point, which 
> to my understanding should be used at this point, and I did not find 
> the correct solution besides passing all the data manually, e.g. like this:
> 
> NTCredentials ntCreds = new NTCredentials(user, password, 
> localMachineName, domainName ); CredentialsProvider credsProvider = 
> new BasicCredentialsProvider(); setCredentials( new 
> AuthScope(host,port), ntCreds); 
> setDefaultCredentialsProvider(credsProvider);
> setProxyAuthenticationStrategy(new ProxyAuthenticationStrategy());
> 
> However, here localMachineName and domainName have to be guessed somehow...
> 
> What is the correct solution to set a proxy in this setting?
> 

Do not set fully initialized connection manager. It makes all connection 
management settings have no effect.

Oleg


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
For additional commands, e-mail: httpclient-users-h...@hc.apache.org

Reply via email to