title: HttpUrlConnection.getInputStream returns empty stream in Android
body: <p>I make a GET request to a server using HttpUrlConnection.
  After connecting:</p>
  
  <ol>
  <li>I get response code: 200</li>
  <li>I get response message: OK</li>
  <li><p>I get input stream, no exception thrown but:</p>
  
  <ul>
  <li>in a standalone program I get the body of the response, as expected:</li>
  </ul>
  
  <p>{"name":"my name","birthday":"01/01/1970","id":"100002215110084"}</p>
  
  <ul>
  <li>in a android activity, the stream is empty (available() == 0), and thus I can't get
  any text out.</li>
  </ul></li>
  </ol>
  
  <p>Any hint or trail to follow? Thanks.</p>
  
  <p>EDIT: here it is the code</p>
  
  <p>Please note: I use <code>import java.net.HttpURLConnection;</code> This is the standard
  http Java library. <strong>I don't want to use any other external library</strong>. In fact
  I did have problems in android using the library httpclient from apache (some of their anonymous .class can't be used by the apk compiler).</p>
  
  <p>Well, the code:</p>
  
  <pre><code>URLConnection theConnection;
  theConnection = new URL("www.example.com?query=value").openConnection(); 
  
  theConnection.setRequestProperty("Accept-Charset", "UTF-8");
  
  HttpURLConnection httpConn = (HttpURLConnection) theConnection;
  
  
  int responseCode = httpConn.getResponseCode();
  String responseMessage = httpConn.getResponseMessage();
  
  InputStream is = null;
  if (responseCode &gt;= 400) {
      is = httpConn.getErrorStream();
  } else {
      is = httpConn.getInputStream();
  }
  
  
  String resp = responseCode + "\n" + responseMessage + "\n&gt;" + Util.streamToString(is) + "&lt;\n";
  
  return resp;
  </code></pre>
  
  <p>I see:</p>
  
  <blockquote>
    <p>200<br>
    OK<br>
    the body of the response</p>
  </blockquote>
  
  <p>but only</p>
  
  <blockquote>
    <p>200
    OK</p>
  </blockquote>
  
  <p>in android</p>