1、实现接口HttpConnectionManager新加实现类A,直接复制SimpleHttpConnectionManager的类内容。
2、A类增加方法
public Socket getSocket() {
return this.httpConnection.getSocket();
}
3、为httpClient指定HttpConnectionManager ?
方法为 httpClient 指定httpClient.setHttpConnectionManager(new A());
4、httpClient.executeMethod执行后获取httpClient.getHttpConnectionManager(),强制转换为A.
5、通过getSocket().getInetAddress().getHostAddress()可以获取到当次请求真实ip.
如何通过httpclient获取访问域名的真实ip
原文地址:http://blog.51cto.com/chend/2068906