On Wed, 2012-07-04 at 02:38 -0700, paul_b wrote: > Thanks for your reply. Looking at my code, which I think there is nothing > different than the examples, I cant see how... I have included a snippet of > my code below. I was expecting something in the ConnRoutePNames according > to what you say but there doesnt seem to be. > > httpclient.getCredentialsProvider().setCredentials( > new AuthScope(PROXY_URL, PROXY_PORT), > new > UsernamePasswordCredentials(credentials.getUsername(), > credentials.getPassword())); > HttpHost proxy = new HttpHost(PROXY_URL, PROXY_PORT); > > httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, > proxy); > >
Careful with the PROXY_URL variable. It must contain a hostname (such as locahost), not a URL (such as http://localhost/). All you have to do is to add credentials for the target host: httpclient.getCredentialsProvider().setCredentials( new AuthScope(PROXY_HOST, PROXY_PORT), new UsernamePasswordCredentials("user:password"); httpclient.getCredentialsProvider().setCredentials( new AuthScope(TARGET_HOST, TARGET_PORT), new UsernamePasswordCredentials("user:password"); HttpHost proxy = new HttpHost(PROXY_HOST, PROXY_PORT); httpclient.getParams().setParameter( ConnRoutePNames.DEFAULT_PROXY, proxy); Oleg > > olegk wrote: > > > > On Wed, 2012-07-04 at 01:29 -0700, paul_b wrote: > >> Hi, > >> I have been looking on the internet and unable to find an example of > >> the > >> DefaultHttpClient class with the capability of using user authentication > >> for > >> both proxy and target. I can see from the document that there are > >> examples > >> of user authentication for either proxy and target, both not both! I can > >> see examples of older libraries with this scenario, but not the latest. > >> I > >> would much appreciate if someone could post an example. > >> > >> Cheers, > >> paul > > > > There is nothing special about it. Just make sure you provide > > credentials for both target and proxy hosts. HttpClient will do the rest > > automatically. > > > > Oleg > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [email protected] > > For additional commands, e-mail: [email protected] > > > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
