commons-httpclient removed port 80 from the Host header after executeMethod
I created a GET HTTPMethod with a specified host and port and ex开发者_StackOverflow中文版ecute that from Httpclient.executeMethod(). However, by the time the host receive it, the port is truncated from the Host Header in the HTTP request.
The Host header information in the HttpMethod prior to executing is the following: User-Agent: Me Host: stackoverflow.com:80
at the time received by the host:
User-Agent: Jakarta Commons-HttpClient/3.1 Host: stackoverflow.com
I have seen posting where I can set the User-Agent in the HTTPClient prior to executing. But, I've tried that with the host via HostConfiguration, and no luck. Anyone has seen this problem before and resolved it such that the host will not change?
This does not happened when I used the other httpclient package, or when I hit different port.
Found the answer: How can I override the "Host" header in the request when using Apache commons HttpClient
精彩评论