You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by tomgordon <to...@mac.com> on 2008/09/04 15:47:57 UTC

Re: Host header from URL instead of HttpHost


You can do this:

getMethod.getParams().setVirtualHost("serverA");

Don't bother setting the "Host" header directly - HttpClient will either use
the virtual host as set above, or take it directly from the connection.

-Tom


Q Beukes wrote:
> 
> Hey,
> 
> I am trying to connect to 1 of 3 machines to retrieve content. Using
> HTTP I decided to use HttpClient. I want to use some of the features
> provided by HttpClient, so HttpCore is preferably not an option.
> 
> All these hosts are configured to accept connections for the same host
> name, lets call it "serverA". I calculate which one to connect to on
> my side though, so I specify it with IP address. So I basically want
> to do something like this:
> Connect to X.X.X.X, but send the request:
> GET http://serverA/file/to/get.html HTTP/1.1
> Host: serverA
> 
> Is there any way to achieve this?
> 
> I used to use sun.net.www.protocol.http.HttpURLConnection, which could
> do this easily, but for certain feature requirements we decided to
> switch to HttpClient, like it's multithreading and connection
> management, cookie management and all the other great features. This
> is a major problem though... can HttpClient even do this?
> 
> I figured I might do this by specifying the host as a proxy. But proxy
> requests specify extra headers that aren't intended for direct to
> server requests, like "Proxy-connection".
> 
> -- 
> Quintin Beukes
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Host-header-from-URL-instead-of-HttpHost-tp17710586p19309018.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


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