Android's HttpURLConnection throws EOFException on HEAD requests

前端 未结 1 1817
难免孤独
难免孤独 2020-12-03 17:28

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         


        
相关标签:
1条回答
  • 2020-12-03 17:37

    Turned out this is a known bug in Android's class implementation. Calling Connection.setRequestProperty( "Accept-Encoding", "" ); before connecting can be used as workaround.

    https://code.google.com/p/android/issues/detail?id=24672

    0 讨论(0)
提交回复
热议问题