hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Ma" <javahe...@hotmail.com>
Subject Help -- Proxy
Date Mon, 25 Aug 2003 04:21:28 GMT

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 

    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();
        HttpState state=new HttpState();
        UsernamePasswordCredentials userpass=
               new UsernamePasswordCredentials("myname","mypass");
        state.setProxyCredentials(null, null, userpass);
        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: 

Please help me


MSN 8: Get 6 months for $9.95/month. http://join.msn.com/?page=dept/dialup

View raw message