title: Android's HttpURLConnection throws EOFException on HEAD requests
body: <p>This small code snippet runs fine on my Mac's JVM. Unfortunately it crashes when executed on Android 4.2.</p>
  
  <pre><code>import java.net.HttpURLConnection;
  import java.net.URL;
  
  public class App
  {
      public static void main( String... arguments ) throws Exception
      {
          HttpURLConnection connection = (HttpURLConnection) new URL( "https://github.com" ).openConnection();
          connection.setRequestMethod( "HEAD" );
  
          System.out.println( connection.getResponseCode() + "" );
      }
  }
  </code></pre>
  
  <p>If I replace <code>https://github.com</code> with <code>https://www.facebook.com</code> it works fine but I'm failing to figure out why.</p>
  
  <p>The exception does not contain a message; so here's at least the stack trace.</p>
  
  <pre><code>java.io.EOFException
          at java.util.zip.GZIPInputStream.readFully(GZIPInputStream.java:206)
          at java.util.zip.GZIPInputStream.&lt;init&gt;(GZIPInputStream.java:98)
          at java.util.zip.GZIPInputStream.&lt;init&gt;(GZIPInputStream.java:81)
          at libcore.net.http.HttpEngine.initContentStream(HttpEngine.java:541)
          at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:844)
          at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:283)
          at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:495)
          at libcore.net.http.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:134)
  </code></pre>