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 <ol...@apache.org> 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 <simonetrip...@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 <ol...@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-unsubscr...@hc.apache.org
> > > >> For additional commands, e-mail: httpclient-users-h...@hc.apache.org
> > > >>
> > > >>
> > > >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
> > For additional commands, e-mail: httpclient-users-h...@hc.apache.org
> >
> >



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
For additional commands, e-mail: httpclient-users-h...@hc.apache.org

Reply via email to