title: Missing cookie in http response in android app
body: <p>I'm trying to make a request to server using apache <strong>HttpClient</strong> from android app and I'm getting response without headers <strong>Set-Cookies</strong>.
  I've tried to do same thing on desktop application and it worked, I've received all headers.
  What am I doing wrong? Help me, please to fix this problem.</p>
  
  <pre><code>HttpClient httpclient1 = new DefaultHttpClient();
          HttpGet req1 = new HttpGet("http://www.example.com");
          req1.addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
          req1.addHeader("Accept-Encoding", "gzip,deflate,sdch");
          req1.addHeader("Accept-Language", "ru,en-US;q=0.8,en;q=0.6,uk;q=0.4");
          req1.addHeader("Connection", "keep-alive");
          req1.addHeader("Host", "www.example.com");
          req1.addHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36");
          String cookie = "";
          try {
              HttpResponse response1 = httpclient1.execute(req1);
              Header[] headers = response1.getAllHeaders();
              for (int i = 0; i &lt; headers.length; i++) {
                  System.out.println(headers[i] + "");
                  if (headers[i].toString().startsWith("Set-Cookie: "))
                      cookie = headers[i].toString().substring(12);
              }   
  
              HttpClient httpclient = new DefaultHttpClient();
  
              HttpPost postRequest = new HttpPost("http://www.example.com/1.php");
              postRequest.addHeader("Referer", "http://www.example.com/2.php");
              if (cookie.length() &gt; 0) {
                  cookie = cookie.replace(" path=/", "");
                  postRequest.addHeader("Cookie", cookie);
              }
  
              List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;();
              nameValuePairs.add(new BasicNameValuePair("username", "my-username"));
              nameValuePairs.add(new BasicNameValuePair("password", "my-password"));
              postRequest.setEntity(new UrlEncodedFormEntity(nameValuePairs));
  
              HttpResponse response = httpclient.execute(postRequest);
              Header[] hs = postRequest.getAllHeaders();
              for (int i = 0; i &lt; hs.length; i++) {
                  System.out.println(hs[i] + "");
              }
              System.out.println(response.getStatusLine().getStatusCode() + "");
              Header[] hs3 = response.getAllHeaders();
              for (int i = 0; i &lt; hs3.length; i++) {
                  System.out.println(hs3[i] + "");
              }
          } catch (ClientProtocolException e) {
              e.printStackTrace();
              System.err.println("ClientProtocolException");
          } catch (IOException e) {
              e.printStackTrace();
              System.err.println("IOException");
          }
  </code></pre>
  
  <p>Here's headers that I've received using android app:</p>
  
  <pre><code>200
  Server: nginx/0.7.67
  Date: Sun, 06 Jul 2014 16:25:26 GMT
  Content-Type: text/html; charset=utf-8
  Transfer-Encoding: chunked
  Connection: keep-alive
  X-Powered-By: PHP/5.3.3-7+squeeze14
  Expires: Thu, 19 Nov 1981 08:52:00 GMT
  Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
  Pragma: no-cache
  Vary: Accept-Encoding
  </code></pre>
  
  <p>And here's from desktop app:</p>
  
  <pre><code>302
  Server: nginx/0.7.67
  Date: Sun, 06 Jul 2014 16:39:55 GMT
  Content-Type: text/html
  Connection: keep-alive
  X-Powered-By: PHP/5.3.3-7+squeeze14
  Expires: Thu, 19 Nov 1981 08:52:00 GMT
  Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
  Pragma: no-cache
  Location: http://www.example.com/
  Set-Cookie: uid=12345; expires=Tue, 19-Jan-2038 03:14:07 GMT; path=/
  Set-Cookie: pass=11111111111111111111111111111111; expires=Tue, 19-Jan-2038 03:14:07 GMT; path=/
  Vary: Accept-Encoding
  Content-Length: 139
  </code></pre>