Android's HttpURLConnection throws EOFException on HEAD requests
This small code snippet runs fine on my Mac's JVM. Unfortunately it crashes when executed on 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() + "" ); } } If I replace https://github.com with https://www.facebook.com it works fine but I'm failing to figure out why. The exception does not contain a message;