hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Becke <be...@u.washington.edu>
Subject Re: Help -- Proxy
Date Mon, 25 Aug 2003 12:30:16 GMT
Hi Mike,

You've pretty much got it.  If you are authenticating to a NTLM proxy, 
you have to use NTCredentials instead of UsernamePasswordCredentials.  
Also, just to note, you don't have to create instances of 
HostConfiguration or HttpState.  You can use the ones returned from 
HttpClient.

Mike

On Monday, August 25, 2003, at 12:21 AM, Mike Ma wrote:

>
>
> First, thank you all for this wonderful httpclient library. I found it 
> this weekend, and started to test the functionalities that I want. It 
> works very nicely except I could not figure out how to configurate a 
> proxy server. I really need to access internet using this httpclient 
> through my company's proxy server.
>
> I know the following codes work in Proxy configuration when I use 
> JDK's URLConnection:
>
> ------------
>    System.getProperties().put("proxySet", "true");
>    System.getProperties().put("proxyHost", 
> "www-ad-proxy.mycompany.com");
>     System.getProperties().put("proxyPort", "80");
>    URL url=new URL("some-url");
>    URLConnection conn=url.openConnection();
>    String authString="myusername:mypassword";
>    BASE64Encoder encoder=new BASE64Encoder();
>    String auth="Basic "+encoder.encode(authString.getBytes());
>    conn.setRequestProperty("Proxy-Authorization", auth);
> ------------
>
> I tried to do a get method using this httpclient module as following
> ---------
>
>        HttpClient client=new HttpClient();
>        HostConfiguration hostConfig=new HostConfiguration();
>        hostConfig.setProxy("www-ad-proxy.mycompany.com",80);
>        HttpState state=new HttpState();
>        UsernamePasswordCredentials userpass=
>               new UsernamePasswordCredentials("myname","mypass");
>        state.setProxyCredentials(null, null, userpass);
>        client.setHostConfiguration(hostConfig);
>        client.setState(state);
>        GetMethod method=new GetMethod("http://www.apache.org");
>       ....
> -----
>
> It did not work. The warning message was:
> [WARN] HttpMethodBase - -Credentials cannot be used for NTLM 
> authentication: myname:mypass
>
>
> Please help me
>
> Thanks
> Mike
>
> _________________________________________________________________
> MSN 8: Get 6 months for $9.95/month. 
> http://join.msn.com/?page=dept/dialup
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: 
> commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: 
> commons-httpclient-dev-help@jakarta.apache.org
>


Mime
View raw message