Return-Path: X-Original-To: apmail-hc-httpclient-users-archive@www.apache.org Delivered-To: apmail-hc-httpclient-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3C261104E2 for ; Wed, 10 Apr 2013 10:25:33 +0000 (UTC) Received: (qmail 97531 invoked by uid 500); 10 Apr 2013 10:25:33 -0000 Delivered-To: apmail-hc-httpclient-users-archive@hc.apache.org Received: (qmail 97034 invoked by uid 500); 10 Apr 2013 10:25:26 -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 96992 invoked by uid 99); 10 Apr 2013 10:25:25 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 10 Apr 2013 10:25:25 +0000 X-ASF-Spam-Status: No, hits=0.7 required=5.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [217.150.250.48] (HELO kalnich.nine.ch) (217.150.250.48) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 10 Apr 2013 10:25:20 +0000 Received: from [192.168.1.121] (77-57-197-206.dclient.hispeed.ch [77.57.197.206]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by kalnich.nine.ch (Postfix) with ESMTPSA id 3A95DB802DA for ; Wed, 10 Apr 2013 12:24:58 +0200 (CEST) Message-ID: <1365589497.16348.48.camel@ubuntu> Subject: Re: Proxy exceptions From: Oleg Kalnichevski To: HttpClient User Discussion Date: Wed, 10 Apr 2013 12:24:57 +0200 In-Reply-To: References: <1365440817.9187.24.camel@ubuntu> <1365454943.9187.34.camel@ubuntu> <1365579268.16348.7.camel@ubuntu> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.6.2-0ubuntu0.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org On Wed, 2013-04-10 at 10:42 +0200, Simone Tripodi wrote: > Hi Oleg, > > thanks again for your help! All these questions are about looking for a > solution for HTTPCLIENT-1238: the scenario is that a power-user can > add/upload/delete proxy configurations dynamically, so the best moment to > determine which proxy cinfiguration is available (if any) is when > DefaultRoutePlanner#determineRoute() is invoked... in that way, we can > avoid an HttpClient instance is built with a Proxy configuration which > could be not available at the time of the invocation. > > Anyway, I am open to every idea, since I am not expert about HttpClient > APIs :) > Do you have any suggestion? > If I had to implement this feature I would consider using a custom route planner and a credentials provider implementations both backed by the same structure (a proxy selector of some sort). This would ensure consistency of proxy settings without having to manually update the credential provider from inside the route planner. Hope this helps Oleg > Many thanks in advance, all the best! > -Simo > > > http://people.apache.org/~simonetripodi/ > http://simonetripodi.livejournal.com/ > http://twitter.com/simonetripodi > http://www.99soft.org/ > > > On Wed, Apr 10, 2013 at 9:34 AM, Oleg Kalnichevski wrote: > > > On Tue, 2013-04-09 at 17:42 +0200, Simone Tripodi wrote: > > > Hi again Oleg, > > > > > > I managed my RoutePlanner implementation by extending the > > > DefaultRoutePlanner, which is simple and straightforward :) > > > > > > Now my question is: is there any way to set Proxy's username/password > > > inside the RoutePlanner? > > > > > > > Yes, there is. One can get hold of the actual credentials provider from > > HttpContext. However, I would recommend keeping route planning and > > credential management aspects separate. Is there a really good reason to > > meddle with user credentials from inside HttpRoutePlanner > > implementation? > > > > Cheers > > > > Oleg > > > > > Many thanks in advance, all the best! > > > -Simo > > > > > > > > > http://people.apache.org/~simonetripodi/ > > > http://simonetripodi.livejournal.com/ > > > http://twitter.com/simonetripodi > > > http://www.99soft.org/ > > > > > > > > > On Mon, Apr 8, 2013 at 11:02 PM, Oleg Kalnichevski > > wrote: > > > > > > > On Mon, 2013-04-08 at 21:25 +0200, Simone Tripodi wrote: > > > > > Hi again Oleg, > > > > > > > > > > please apologise for the silly question, but... could you provide me > > > > please > > > > > a sample of how to use the RoutePlanner in the way I described? > > > > > > > > > > Sorry, but I haven't figured out how to... many thanks in advance! > > > > > > > > > > best, > > > > > -Simo > > > > > > > > > > > > > > > > > > Something like that should probably suffice. > > > > > > > > Hope this helps > > > > > > > > Oleg > > > > > > > > --- > > > > public HttpRoute determineRoute( > > > > final HttpHost host, > > > > final HttpRequest request, > > > > final HttpContext context) throws HttpException { > > > > final HttpClientContext clientContext = > > > > HttpClientContext.adapt(context); > > > > RequestConfig config = clientContext.getRequestConfig(); > > > > InetAddress local = config.getLocalAddress(); > > > > HttpHost proxy = config.getProxy(); > > > > > > > > // bypass proxy for localhost > > > > if (host.getHostName().equalsIgnoreCase("localhost") > > > > || host.getHostName().equals("127.0.0.1")) { > > > > proxy = null; > > > > } > > > > HttpHost target; > > > > if (host.getPort() <= 0) { > > > > target = new HttpHost( > > > > host.getHostName(), > > > > this.schemePortResolver.resolve(host), > > > > host.getSchemeName()); > > > > } else { > > > > target = host; > > > > } > > > > boolean secure = target.getSchemeName().equalsIgnoreCase("https"); > > > > if (proxy == null) { > > > > return new HttpRoute(target, local, secure); > > > > } else { > > > > return new HttpRoute(target, local, proxy, secure); > > > > } > > > > } > > > > > > > > > > > > > > > > > > > > > http://people.apache.org/~simonetripodi/ > > > > > http://simonetripodi.livejournal.com/ > > > > > http://twitter.com/simonetripodi > > > > > http://www.99soft.org/ > > > > > > > > > > > > > > > On Mon, Apr 8, 2013 at 8:34 PM, Simone Tripodi < > > simonetripodi@apache.org > > > > >wrote: > > > > > > > > > > > Thanks Oleg, it does indeed! > > > > > > > > > > > > All the best, > > > > > > -Simo > > > > > > > > > > > > http://people.apache.org/~simonetripodi/ > > > > > > http://simonetripodi.livejournal.com/ > > > > > > http://twitter.com/simonetripodi > > > > > > http://www.99soft.org/ > > > > > > > > > > > > > > > > > > On Mon, Apr 8, 2013 at 7:06 PM, Oleg Kalnichevski < > > olegk@apache.org > > > > >wrote: > > > > > > > > > > > >> On Mon, 2013-04-08 at 17:30 +0200, Simone Tripodi wrote: > > > > > >> > Hi all mates, > > > > > >> > > > > > > >> > is there any way to setup exception for proxy, in HttpClient > > > > instances? > > > > > >> > > > > > > >> > I mean, domains such as "localhost" or "127.0.0.1" should be > > > > skipped by > > > > > >> > proxy resolution, as well as more domains which could be > > configured > > > > by > > > > > >> > users - is there any API to achieve it? > > > > > >> > > > > > > >> > Many thanks in advance, all the best! > > > > > >> > -Simo > > > > > >> > > > > > > >> > > > > > >> This is what HttpRoutePlanner is for. One can selectively > > construct > > > > > >> different routes based on request properties, target host or > > > > contextual > > > > > >> attributes. > > > > > >> > > > > > >> Hope this helps > > > > > >> > > > > > >> Oleg > > > > > >> > > > > > >> > > > > > >> > > > > > >> > > --------------------------------------------------------------------- > > > > > >> 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 > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > 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