How can I override the “Host” header in the request when using Apache commons HttpClient
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using Jakarta Commons HttpClient 3.1 writing a load test tool that needs to target different servers and pretend like it targeted the correct virtual host in the HTTP server. For that I need to be able to set the "Host" HTTP header in the request to a different host name then the actual host name that I'm connecting to. It seemed pretty obvious that I should use Method.setRequestHeader("Host","fakehostname") , but HttpClient just ignores this and always sends the real host name I'm connecting to in the "Host" header (I've enabled debug