Die HttpURLConnection von Android löst eine EOFException bei HEAD-Anfragen aus

Dieses kleine Code-Snippet läuft problemlos auf der JVM meines Mac. Leider stürzt es ab, wenn es unter Android 4.2 ausgeführt wird.

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() + "" );
    }
}

Wenn ich ersetzehttps://github.com mithttps://www.facebook.com es funktioniert gut, aber ich weiß nicht warum.

Die Ausnahme enthält keine Nachricht. also hier ist wenigstens der Stack-Trace.

java.io.EOFException
        at java.util.zip.GZIPInputStream.readFully(GZIPInputStream.java:206)
        at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:98)
        at java.util.zip.GZIPInputStream.<init>(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)

Antworten auf die Frage(1)

Ihre Antwort auf die Frage