On Wed, Jun 24, 2009 at 02:37:26AM -0700, Angelo Chen wrote:
> 
> Hi,
> 
> I need to use proxy to login to my site, code below works quite well when
> the setEntity line is commented out, if not then I'm getting this error
> returning from proxy server:
> 
> 407 Proxy Authentication Required
> 
> any idea what I'm missing here? Thanks,
> 

Post wire log:

http://hc.apache.org/httpcomponents-client/logging.html

Oleg


> a.c.
> 
> HttpPost httpPost = new HttpPost(loginURL);
> 
> List<NameValuePair> nvps = new ArrayList<NameValuePair>();
> nvps.add(new BasicNameValuePair("uname", "test"));
> nvps.add(new BasicNameValuePair("password", "testpwd"));
> 
> this.setProxyInfo(httpclient);                // set the proxy info
> 
> httpPost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));  // !!!
> comment out this line will remove the  message
> response = httpclient.execute(httpPost);
>  
> 
> private void setProxyInfo(DefaultHttpClient httpClient) {
>       CredentialsProvider credsProvider = new BasicCredentialsProvider();
>       credsProvider.setCredentials(
>               new AuthScope(proxyHost, proxyPort),
>               new UsernamePasswordCredentials(proxyUserName,
> proxyPassword));
>       httpClient.setCredentialsProvider(credsProvider);
> 
>       HttpHost proxy = new HttpHost(proxyHost, proxyPort, "http");
> 
>       HttpParams params = httpClient.getParams();
>       HttpProtocolParams.setUserAgent(params, agent_id);
>       httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,
> proxy);
> 
> 
> -- 
> View this message in context: 
> http://www.nabble.com/httpclient-4.x%3A407-Proxy-Authentication-Required-tp24181617p24181617.html
> Sent from the HttpClient-User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> 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]

Reply via email to