【发布时间】:2010-12-17 03:41:23
【问题描述】:
我有一个 android 1.6 应用程序,我正在尝试获取 HTTP GET 响应的位置标头。但是,当我调用 getLastHeader("location") 时,它返回 null。我什至通过调试器进入响应变量并且没有发送位置标头。我需要在任意网站上执行此操作,但使用 google 进行测试仍然会产生事故。我认为位置是要读取的默认标题? android 1.6 不读取位置标头吗?我的代码如下:
HttpClient httpClient = DefaultHttpClient();
HttpGet httpGet = new HttpGet("http://google.com");
try
{
HttpResponse response = httpClient.execute(httpGet);
if(response.getStatusLine().getStatusCode() == 200)
{
Header h = response.getLastHeader("location");
String location = h.getValue();
}
}
非常感谢您的帮助 :) 我正在寻找获取位置的解决方案或解释为什么我没有得到它:/
【问题讨论】:
标签: java android http-headers location