java - org.apache.http.impl.client.CloseableHttpClient Proxy Authentication -


my application https requests different targets , have proxy problem.

while client connecting target, 407 (proxy authentication required) target server. clear: client reaches other servers in www already.

how can build closeablehttpclient in general allow proxy auth? can give me short example how allow proxy auth?
double proxy auth (my proxy + external proxy) works?

see "request configuration" section here. in short:

1.) build client:

requestconfig defaultrequestconfig = requestconfig.custom()     .setsockettimeout(5000)     .setconnecttimeout(5000)     .setconnectionrequesttimeout(5000)     .setstaleconnectioncheckenabled(true)     .build();  closeablehttpclient httpclient = httpclients.custom()     .(settingxy)     .setdefaultcookiestore(defaultcookiestore)     .setdefaultcredentialsprovider(defaultcredentialsprovider)     .setdefaultrequestconfig(defaultrequestconfig)     .setdefaultrequestconfig(defaultrequestconfig)     .build(); //you dont need specify proxy here!!! 

2.) build reqeuest(s) this:

httpget httpget = new httpget("http://www.apache.org/"); requestconfig requestconfig = requestconfig.copy(defaultrequestconfig)     .setproxy(new httphost("myproxy", 8080))     .build(); httpget.setconfig(requestconfig); 

3.) then

defaultcredentialsprovider.setcredentials(new authscope(proxy.gethostname(), proxy.getport()), proxycredentials);  httpget httpget = new httpget("http://www.apache.org/"); httpurirequest request= httpget; closeablehttpresponse response = httpclient.execute(request, context); 

hope helps someone.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -