After searching for a little more, and, getting a hint from Olegโs answer, I found the HttpMethodParams :: setVirtualHost () method.
when the HttpClient formats the request, it always creates a "Host" header immediately before sending the request, so it cannot be redefined as a standard header. But before the host name for the "Host" header is created from the URL, the HttpClient checks the HttpMethodParams object to see if the user wants to redefine the host name. This only cancels the host name, not the port, so it will be easier to use, although not as intuitively as we would like.
The code to use might look like this:
Method m = new GetMethod("http://some-site/some/path"); m.getParams().setVirtualHost("some-other-site"); client.executeMethod(m);
Guss
source share