如何獲取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