hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Quintin Beukes" <quin...@last.za.net>
Subject Re: Custom Route
Date Sat, 07 Jun 2008 21:23:06 GMT
Hey All,

Good news. After a lot of debug stepping and trial/error I think I
finally figured out how to do this.

You create the HttpHost object you wish to send as the host request header.
Then you do the following (where request is your request object and
requestHost is the HttpHost you setup for the header).

request = new BasicHttpRequest(method, url.toExternalForm(),
request.getParams().setParameter(ClientPNames.VIRTUAL_HOST, requestHost);

So far this seems to be the most correct way. If anyone knows a better
or more correct way, please let me know.


On Sat, Jun 7, 2008 at 10:32 PM, Quintin Beukes <quintin@last.za.net> wrote:
> Hey,
> I found a possible solution to my problem, but I don't know how to approach it.
> One way to do it is to set the Host header. Then it does the
> connection to whatever HttpHost object I set up, and sends the host
> header I define.
> But this doesn't feel right. I would ideally want it to connect to
> server X, but use the header specified in the URL. I noticed in the
> source that it uses an HttpRoute object to specify where it connects
> to (I might have misread/misinterpreted it). Eitherway, is there a
> more correct, or better way to do this?
> I was thinking something along the lines of:
> 1. Use HttpHost to specify the host header
> 2. Specify a route to use via some other technique
> 3. Then it connects to the route in (2.) and sends the request line,
> ex. "GET /path/to HTTP/1.1", and then the host specified in (1.) like
> "Host: myhost.com:8581"
> OR something like this:
> 1. Connect to the host/port specified in HttpHost
> 2. Then HttpClient uses the host specified in the URI string (if any)
> to create the Host header.
> --
> Quintin Beukes

Quintin Beukes

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

View raw message