如何获取HTTPResponse的URL? 我想:如何获取HTTPResponse的URL
response.getHeaders("Locations")
但我得到:
11-15 21:14:03.355: INFO/System.out(880): [Lorg.apache.http.Header;@43ea9568
如何获取HTTPResponse的URL? 我想:如何获取HTTPResponse的URL
response.getHeaders("Locations")
但我得到:
11-15 21:14:03.355: INFO/System.out(880): [Lorg.apache.http.Header;@43ea9568
你也许会认为客户端重定向到一个新的URL在这种情况下,你要设置Location
不Locations
要求有网址,响应只是数据包发送回客户端。
假设Location头是你想尝试什么:'response.getLastHeader( “位置”)的getValue()' – 2010-11-15 23:23:54
@Alexandre感谢编辑但我确实意味着设置 - 使用“Location:”标题是重定向输出的常用方法。 – Basic 2010-11-16 10:47:09
对不起。我虽然是一个错字。但是,在这种情况下,设置“Location”标题有什么意义? OP正在处理来自http *客户端*库的*响应*对象。 – 2010-11-16 11:37:16
试试这个
for(Header header : response.getHeaders("Location")) {
System.out.println("Location from connect:" + header.getValue());
}
HTTP响应没有网址 – 2010-11-15 21:24:49