Return-Path: Mailing-List: contact commons-httpclient-dev-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list commons-httpclient-dev@jakarta.apache.org Received: (qmail 1963 invoked from network); 25 Aug 2003 12:53:46 -0000 Received: from mxout2.cac.washington.edu (140.142.33.4) by daedalus.apache.org with SMTP; 25 Aug 2003 12:53:46 -0000 Received: from smtp.washington.edu (smtp.washington.edu [140.142.32.139]) by mxout2.cac.washington.edu (8.12.9+UW03.06/8.12.9+UW03.06) with ESMTP id h7PCULxu007048 for ; Mon, 25 Aug 2003 05:30:21 -0700 Received: from u.washington.edu (pool-151-199-25-62.bos.east.verizon.net [151.199.25.62]) (authenticated bits=0) by smtp.washington.edu (8.12.9+UW03.06/8.12.9+UW03.06) with ESMTP id h7PCUJ49005612 (version=TLSv1/SSLv3 cipher=DES-CBC3-SHA bits=168 verify=NOT) for ; Mon, 25 Aug 2003 05:30:20 -0700 Date: Mon, 25 Aug 2003 08:30:16 -0400 Subject: Re: Help -- Proxy Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v552) From: Michael Becke To: "Commons HttpClient Project" Content-Transfer-Encoding: 7bit In-Reply-To: Message-Id: X-Mailer: Apple Mail (2.552) X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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 >