我可以使用 Apache HttpClient 获取响应服务器名称/IP 吗?

发布于 2024-08-02 22:44:46 字数 190 浏览 3 评论 0原文

我使用 Apache HttpClient 3.x 来联系一个大 IP,然后该 IP 将我的请求重定向到 1-N 台机器中的一台。不过,我们需要知道 N 台机器中的哪一台实际接收了请求,但我不确定如何获取此信息。我查看了响应标头,但没有成功,所以我想知道此信息是否确实在任何地方提供?是否有一个帮助程序/实用程序类可以用来获取任何其他元数据?

谢谢。

I'm using Apache HttpClient 3.x for contacting a Big IP that will then redirect my request to one of 1-N machines. We have the need to know which of the N machines actually picked up the request though, and I'm not sure how to get this information. I looked through the Response headers with no luck, so I'm wondering if this information is actually provided anywhere? Is there a helper/utility class I can use to get any additional metadata?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

治碍 2024-08-09 22:44:46

如果请求被重定向并且您需要新位置,则需要在该方法上设置 setFollowRedirects(false) 并自行处理重定向。

发送请求后,检查 getStatusCode() 是否有 302 以及 getResponseHeader("Location") 是否有新地址。然后通过setURI()更改地址并再次发送。

If the request is redirected and you need the new location, you need to setFollowRedirects(false) on the method and handle the redirect yourself.

After sending the request, check getStatusCode() for 302 and getResponseHeader("Location") for the new address. Than change the address by setURI() and send again.

渡你暖光 2024-08-09 22:44:46

或者您可以使用 mod_headers 并在每个标题上插入唯一的标头 ID您的 Apache httpd 服务器;-)

Or you could just use mod_headers and insert a unique Header ID on each one of your Apache httpd servers ;-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文