Return-Path: Delivered-To: apmail-hc-httpclient-users-archive@www.apache.org Received: (qmail 8726 invoked from network); 18 Feb 2009 19:39:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Feb 2009 19:39:55 -0000 Received: (qmail 82748 invoked by uid 500); 18 Feb 2009 19:39:54 -0000 Delivered-To: apmail-hc-httpclient-users-archive@hc.apache.org Received: (qmail 82362 invoked by uid 500); 18 Feb 2009 19:39:53 -0000 Mailing-List: contact httpclient-users-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpClient User Discussion" Delivered-To: mailing list httpclient-users@hc.apache.org Received: (qmail 82257 invoked by uid 99); 18 Feb 2009 19:39:53 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Feb 2009 11:39:53 -0800 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [217.150.250.44] (HELO ok2consulting.nine.ch) (217.150.250.44) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Feb 2009 19:39:43 +0000 Received: by ok2consulting.nine.ch (Postfix, from userid 1002) id E826019856B; Wed, 18 Feb 2009 20:39:20 +0100 (CET) Received: from [192.168.1.103] (84-75-103-4.dclient.hispeed.ch [84.75.103.4]) by ok2consulting.nine.ch (Postfix) with ESMTP id CDB35198569 for ; Wed, 18 Feb 2009 20:39:18 +0100 (CET) Message-ID: <499C63D1.1080701@apache.org> Date: Wed, 18 Feb 2009 20:38:57 +0100 From: Oleg Kalnichevski User-Agent: Thunderbird 2.0.0.19 (Windows/20081209) MIME-Version: 1.0 To: HttpClient User Discussion Subject: Re: HTTP Client 4.0: proxy settings? References: <868344.47477.qm@web23001.mail.ird.yahoo.com> <91ae21990902181123s372e11fch65ed923a5527d337@mail.gmail.com> In-Reply-To: <91ae21990902181123s372e11fch65ed923a5527d337@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on ok2consulting.nine.ch X-Spam-Level: X-Virus-Checked: Checked by ClamAV on apache.org X-Old-Spam-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.3 Subhash Chandran wrote: > This is how I do it:: > > String proxyHost = ...; > int proxyPort = ...; > String proxyUsername = ...; > String proxyPassword = ...; > > final HttpHost hcProxyHost = new HttpHost(proxyHost, proxyPort, "http"); > httpclient.getCredentialsProvider().setCredentials( > new AuthScope(proxyHost, proxyPort), > new UsernamePasswordCredentials(proxyUsername, > new String(proxyPassword))); > httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, hcProxyHost); > > Subhash. > > > On Wed, Feb 18, 2009 at 11:25 PM, Florent Georges wrote: >> Hi, >> >> I am evaluating the impact of migrating from HTTP Client 3.1 >> to 4.0, and this is going well so far. But I couldn't find a >> way to set proxy settings. In 3.1 I do (error management left >> for clarity): >> >> String host = System.getProperty("http.proxyHost"); >> String port = System.getProperty("http.proxyPort"); >> client.getHostConfiguration() >> . setProxy(host, Integer.parseInt(port)); >> >> As an aside question, shouldn't the client take the system >> properties http.proxy* and https.proxy* into account? >> It depends. Libraries that make use of system properties may have issues when running in a managed environment such as an EJB container. If you want HttpClient to use proxy system properties, try out the route planner implementation based on java.net.ProxySelector --- DefaultHttpClient httpclient = new DefaultHttpClient(); ProxySelectorRoutePlanner routePlanner = new ProxySelectorRoutePlanner( httpclient.getConnectionManager().getSchemeRegistry(), ProxySelector.getDefault()); httpclient.setRoutePlanner(routePlanner); --- Oleg >> Regards, >> >> -- >> Florent Georges >> http://www.fgeorges.org/ >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org >> For additional commands, e-mail: httpclient-users-help@hc.apache.org >> >> > > > --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org For additional commands, e-mail: httpclient-users-help@hc.apache.org