hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rodrigo B. Campacci" <rbcampa...@yahoo.com.br>
Subject RE: Problem with Proxy Basic Authentication
Date Mon, 24 Jan 2011 23:50:46 GMT
Hi,

I'm trying to make a GET request through a HTTP proxy (squid) with basic
authentication (user and password).

I found a sample of how to do that using version 3.0, but for version 4.x I
can't found this.

I'm using the code below, but it isn't working.

    	HttpRequestBase httpmethod = null;
    	HttpResponse response = null;
    	DefaultHttpClient httpclient = null;
    	HttpHost proxy = null; 
    	
      StringBuilder resultText = new StringBuilder("");
            	
      httpclient = new DefaultHttpClient();
            	
      proxy = new HttpHost(proxyHost, proxyPort);
      httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,
proxy);
      
	httpclient.getCredentialsProvider().setCredentials(
            					new AuthScope(proxyHost,
proxyPort), 
            					new
UsernamePasswordCredentials(proxyUserName, proxyPassword));

	httpmethod = new HttpGet(url);           
      response = httpclient.execute(httpmethod);

Below an extract from the log:
2011/01/24 00:13:47:054 GMT [DEBUG] DefaultHttpClient - Proxy requested
authentication
2011/01/24 00:13:47:054 GMT [DEBUG] DefaultProxyAuthenticationHandler -
Authentication schemes in the order of preference: [negotiate, NTLM, Digest,
Basic]
2011/01/24 00:13:47:054 GMT [DEBUG] DefaultProxyAuthenticationHandler -
Challenge for negotiate authentication scheme not available
2011/01/24 00:13:47:055 GMT [DEBUG] DefaultProxyAuthenticationHandler -
Challenge for NTLM authentication scheme not available
2011/01/24 00:13:47:055 GMT [DEBUG] DefaultProxyAuthenticationHandler -
Challenge for Digest authentication scheme not available
2011/01/24 00:13:47:055 GMT [DEBUG] DefaultProxyAuthenticationHandler -
Basic authentication scheme selected
2011/01/24 00:13:47:064 GMT [DEBUG] DefaultHttpClient - Authorization
challenge processed
2011/01/24 00:13:47:065 GMT [DEBUG] DefaultHttpClient - Authentication
scope: BASIC '*Enter user and password*'@192.168.160.3:8080
2011/01/24 00:13:47:065 GMT [DEBUG] DefaultHttpClient - Found credentials
2011/01/24 00:13:47:066 GMT [DEBUG] DefaultClientConnection - Connection
closed
2011/01/24 00:13:47:066 GMT [DEBUG] DefaultClientConnectionOperator -
Connecting to /192.168.160.3:8080
2011/01/24 00:13:47:741 GMT [DEBUG] RequestAddCookies - CookieSpec selected:
best-match
2011/01/24 00:13:47:747 GMT [DEBUG] DefaultClientConnection - Connection
shut down

Anyone could help?

Thanks,

Rodrigo B. Campacci
rbcampacci@yahoo.com.br 



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


Mime
View raw message