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? 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 <[email protected]> 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 <[email protected]> > 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 < > [email protected] > > > >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 < > [email protected] > > > >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: > [email protected] > > > > >> For additional commands, e-mail: > [email protected] > > > > >> > > > > >> > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [email protected] > > > For additional commands, e-mail: [email protected] > > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
