i made code below.. want header infomation "location" couldn't "location" header..
httpclient myclient = new defaulthttpclient(); string url = "http://goo.gl/xnk93q"; httpget myget = new httpget(url); httpresponse response = null; response = myclient.execute(myget); httpentity entity = response.getentity(); system.out.println("response:-------------------"); system.out.println(response.getstatusline()); headers = response.getallheaders(); for(header h:headers){ system.out.println(h.getname() + ": " + h.getvalue()); }
the result log below
08-23 10:44:22.271: i/system.out(24538): request:------------------- 08-23 10:44:22.271: i/system.out(24538): http://goo.gl/xnk93q http/1.1 08-23 10:44:23.703: i/system.out(24538): response:------------------- 08-23 10:44:23.703: i/system.out(24538): http/1.1 200 ok 08-23 10:44:23.703: i/system.out(24538): cache-control: public, max-age=18 08-23 10:44:23.703: i/system.out(24538): content-type: text/html; charset=utf-8 08-23 10:44:23.713: i/system.out(24538): expires: fri, 23 aug 2013 01:44:43 gmt 08-23 10:44:23.713: i/system.out(24538): last-modified: fri, 23 aug 2013 01:43:43 gmt 08-23 10:44:23.713: i/system.out(24538): vary: * 08-23 10:44:23.713: i/system.out(24538): x-frame-options: sameorigin 08-23 10:44:23.713: i/system.out(24538): date: fri, 23 aug 2013 01:44:24 gmt 08-23 10:44:23.713: i/system.out(24538): content-length: 47292
but when check same url test on site http://www.webconfs.com/http-header-check.php test site show me "location" header info
http/1.0 301 moved permanently => content-type => text/html; charset=utf-8 cache-control => no-cache, no-store, max-age=0, must-revalidate pragma => no-cache expires => fri, 01 jan 1990 00:00:00 gmt date => fri, 23 aug 2013 01:43:13 gmt **location => http://stackoverflow.com/questions/14749307/302-redirect-from-http-to-https-in-android-using-dropbox-short-hyperlinks** x-content-type-options => nosniff x-frame-options => sameorigin x-xss-protection => 1; mode=block server => gse alternate-protocol => 80:quic
** why there different result between "my android app" , "web site"?