commons-httpclient 在executeMethod之后从主机标头中删除了端口80
我创建了一个具有指定主机和端口的 GET HTTPMethod,并从 Httpclient.executeMethod() 执行该方法。但是,当主机收到该端口时,该端口将从 HTTP 请求中的主机标头中截断。
执行前HttpMethod中的Host头信息如下: 用户代理:我 主机:stackoverflow.com:80
主机收到的时间:
用户代理:Jakarta Commons-HttpClient/3.1 主机:stackoverflow.com
我看到过帖子,我可以在执行之前在 HTTPClient 中设置用户代理。但是,我已经通过 HostConfiguration 对主机进行了尝试,但没有成功。有人以前见过这个问题并解决了它,这样主机就不会改变吗?
当我使用其他 httpclient 包或访问不同端口时,不会发生这种情况。
I created a GET HTTPMethod with a specified host and port and execute 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论