java android http httpurlconnection urlconnection

java - HttpURLConnection de Android lanza la excepción EOFException en las solicitudes HEAD



(1)

Este pequeño fragmento de código funciona bien en la JVM de mi Mac. Lamentablemente se bloquea cuando se ejecuta en Android 4.2.

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

Si sustituyo https://github.com por https://www.facebook.com , funciona bien, pero no consigo entender por qué.

La excepción no contiene un mensaje; Así que aquí está, al menos, el rastro de pila.

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)