hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Francois-Xavier Bonnet <fx.bon...@gmail.com>
Subject HttpClient and virtual hosts
Date Mon, 23 Dec 2013 09:21:36 GMT
Hi,

I am trying to migrate to HttpClient 4.3 and I cannot find a way to do what
I used to do before with virtual hosts without using any deprecated api.
My goal is to be able to send a request to a server but using a "Host"
header with a different server name.

I am using a HttpClient with cache and calling
method org.apache.http.client.HttpClient.execute(HttpHost, HttpRequest,
HttpContext)
I found 4 different places I can set a host:

   - as the first parameter of execute method
   - in the URI of the request
   - by calling
   method org.apache.http.protocol.HttpCoreContext.setTargetHost(HttpHost)
   - by setting a Host header in the request

I have tried to debug and it looks like when send a request, the
destination server is identified by using 1) the one ine the URI 2) the
first parameter of execute method if no host is set in the uri 3) the
targetHost in HttpContext. This host is then used to set targetHost is
HttpContext and to determine the HttpRoute to the destination.

My problems:

   - the cookies domains are matched against the targetHost (not the Host
   header) so the cookies are rejected
   - the cache key uses the host name in the HttpRoute which is also the
   targetHost so the cache entries for different virtual hosts on the same
   server are going to be mixed

Did I miss something?

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message