Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Your code works perfectly with me.</p> <p>Try with <a href="http://www.google.it" rel="nofollow">http://www.google.it</a></p> <pre><code> try { HttpClient client = new DefaultHttpClient(); //DefaultHttpClient defaultClient = new DefaultHttpClient(); HttpGet request = new HttpGet(); request.setURI(new URI("http://www.google.it")); HttpResponse response = client.execute(request); Header[] headers = response.getAllHeaders(); //System.out.println("-----------------------------------"); for(int i = 0; i &lt; headers.length; i++) { Header header = headers[i]; Log.i("HeaderName", "Header name: " + header.getName()); Log.i("HeaderValue", "Header value: " + header.getValue()); } } catch(Exception e) {e.printStackTrace();} </code></pre> <p>Output:</p> <pre><code>11-29 15:23:23.630: I/HeaderName(2269): Header name: Date 11-29 15:23:23.630: I/HeaderValue(2269): Header value: Tue, 29 Nov 2011 14:23:23 GMT 11-29 15:23:23.630: I/HeaderName(2269): Header name: Expires 11-29 15:23:23.630: I/HeaderValue(2269): Header value: -1 11-29 15:23:23.630: I/HeaderName(2269): Header name: Cache-Control 11-29 15:23:23.630: I/HeaderValue(2269): Header value: private, max-age=0 11-29 15:23:23.630: I/HeaderName(2269): Header name: Content-Type 11-29 15:23:23.630: I/HeaderValue(2269): Header value: text/html; charset=ISO-8859-1 11-29 15:23:23.630: I/HeaderName(2269): Header name: Set-Cookie 11-29 15:23:23.630: I/HeaderValue(2269): Header value: PREF=ID=125f8d281270e018:FF=0:TM=1322576603:LM=1322576603:S=gPXe6FZbpDuKjcUR; expires=Thu, 28-Nov-2013 14:23:23 GMT; path=/; domain=.google.it 11-29 15:23:23.630: I/HeaderName(2269): Header name: Set-Cookie 11-29 15:23:23.630: I/HeaderValue(2269): Header value: NID=53=hnqogpxyCO2Z4H7khIJtp_5Qlx-qewYq1zso-dAXxdZlYXMY6vQ0Gx01HTz8waYz0ICeJ_roBYRmiD_85PaGL6spuu-c1LP52_qxgvx8sEvMrow1M6Qd2mtgUVIUuD2P; expires=Wed, 30-May-2012 14:23:23 GMT; path=/; domain=.google.it; HttpOnly 11-29 15:23:23.630: I/HeaderName(2269): Header name: Server 11-29 15:23:23.630: I/HeaderValue(2269): Header value: gws 11-29 15:23:23.630: I/HeaderName(2269): Header name: X-XSS-Protection 11-29 15:23:23.630: I/HeaderValue(2269): Header value: 1; mode=block 11-29 15:23:23.630: I/HeaderName(2269): Header name: X-Frame-Options 11-29 15:23:23.630: I/HeaderValue(2269): Header value: SAMEORIGIN 11-29 15:23:23.630: I/HeaderName(2269): Header name: Transfer-Encoding 11-29 15:23:23.630: I/HeaderValue(2269): Header value: chunked </code></pre> <p>Are you sure that the received response should contain the Set-Cookie header?</p> <p>EDIT: Have you added the internet permission to the AndroidManifest.xml file?</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.yourpackage.app" ...&gt; &lt;uses-sdk android:minSdkVersion="##" /&gt; &lt;uses-permission android:name="android.permission.INTERNET" /&gt; &lt;application ...&gt; ... &lt;/application&gt; &lt;/manifest&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload