问题描述
我需要记录 Apache HttpClient 调用的目标 IP 地址。所以要调用的代码是这样的:
public void setForDepartment(String department) {
String url = urlProps.get(department);
HttpGet get = new HttpGet(url);
HttpResponse response = getHttpsClient().execute(get);
}
public CloseableHttpClient getHttpsClient() {
/* code to create the Http Client */
}
记录 URL 非常容易,因为它已传递到方法中。但是要求很明确,需要记录的IP地址。
如何强制查找远程 IP 地址以进行日志记录?如果这使用了“标准”servlet 类,例如 HttpServletRequest
和 HttpServletResponse`,it would be easy to call the
getRemoteAddr()method. That method is not available on the
HttpResponse`` 类。
谁能告诉我我将如何执行查找以便我可以记录它? HttpClient 版本是 apache-httpcomponents 4.5.5 的一部分。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)