hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: HttpHost thread-safe?
Date Wed, 10 Oct 2012 19:33:11 GMT
On Wed, 2012-10-10 at 16:53 +0200, Joan Balaguero wrote:
> Hello,
> 
>  
> 
> When I implement a router planner like this:
> 
>  
> 
> ( . . . )
> 
> public HttpRoute determineRoute(HttpHost target, HttpRequest request,
> HttpContext context) throws HttpException 
> 
> {
> 
>   boolean isHttps = "https".equalsIgnoreCase(target.getSchemeName());
> 
>   HttpHost proxy  = isHttps ? httpsProxy : httpProxy;
> 
>                 
> 
>   if (proxy == null) return new HttpRoute(target, null, isHttps);
> 
>   return new HttpRoute(target, null, proxy, isHttps);
> 
> }
> 
>  
> 
> Can I pass to HttpRoute an already constructed HttpHost (like above)? Or
> should I build a new HttpHost like “return new HttpRoute(target, null, new
> HttpHost(proxy.getHostName(), proxy.getPort(), proxy.getSchemeName()),
> isHttps);” ?
> 

HttpHost is immutable and as such can be safely accessed by multiple
threads.

Oleg



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


Mime
View raw message