[prev in list] [next in list] [prev in thread] [next in thread] 

List:       httpclient-users
Subject:    Re: HttpCoreContext.HTTP_TARGET_HOST equivalent in hc 5
From:       "Francisco A. Lozano" <flozano () gmail ! com>
Date:       2022-10-29 13:59:28
Message-ID: CAP+gH5ZueFekrD3iNqYJ438MJ=dEx8d+h9M3rZwX5Ygf4R7fxw () mail ! gmail ! com
[Download RAW message or body]


Ah, nice! given the request is expected to be in the context:

((HttpRequest)
context.getAttribute(HttpCoreContext.HTTP_REQUEST)).getAuthority().getHostName();

Thanks a lot!

Francisco A. Lozano


El sáb, 29 oct 2022 a las 10:21, Oleg Kalnichevski (<olegk@apache.org>)
escribió:
>
> On Fri, 2022-10-28 at 17:28 +0200, Francisco A. Lozano wrote:
> > Hi,
> >
> > I'm trying to port a tweaked ConnectionKeepAliveStrategy which
> > applies a
> > custom behaviour depending on the target host.
> >
> > With 4.5.x I followed the example in:
> >
https://hc.apache.org/httpcomponents-client-4.5.x/current/tutorial/html/connmgmt.html
> >
> > and obtained the target host with
> >
> >     HttpHost target = (HttpHost)
> > context.getAttribute(HttpCoreContext.HTTP_TARGET_HOST);
> >
> > but this constant is not available anymore in the HttpCoreContext.
> >
> > What is the right way to obtain the target host from the HttpContext
> > when
> > moving to http client 5? I was looking at CONNECTION_ENDPOINT and the
> > remoteAddress of EndpointDetails, but it's not equivalent to a target
> > hostname.
> >
> > Francisco A. Lozano
>
> In 5.x one can get those details directly from the request object. See
> HttpRequest#getScheme and HttpRequest#getAuthority.
>
> Oleg
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic