2010-11-02 58 views

回答

12

它應該是類似於:

HttpClient client = new DefaultHttpClient(); 
HttpParams params = client.getParams(); 
HttpClientParams.setRedirecting(params, false); 
HttpGet method = new HttpGet("http://forecast.weather.gov/zipcity.php?inputstring=90210"); 
HttpResponse resp = client.execute(method); 
String location = resp.getLastHeader("Location").getValue(); 

編輯:我不得不做一些小的調整,但經我測試上述作品。

+0

你怎麼能夠發現這一點?我正在使用.getAllHeaders()函數並將它們全部打印出來,並且未列出位置標題。 – joepetrakovich 2010-11-02 02:01:27

+0

@Petra,使用LiveHttpHeaders和Firebug。我會很快發佈一個例子。你使用的是哪個版本的HttpClient? – 2010-11-02 02:02:03

+0

Android 2.2上的org.apache.http.client模塊 – joepetrakovich 2010-11-02 02:08:58

相關問題