12-05 09:14:12.159: W/System.err(3950): java.io.EOFException
12-05 09:14:12.161: W/System.err(3950): at libcore.io.Streams.readAsciiLine(Streams.java:203)
12-05 09:14:12.161: W/System.err(3950): at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:544)
12-05 09:14:12.162: W/System.err(3950): at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:784)
12-05 09:14:12.162: W/System.err(3950): at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:281)
12-05 09:14:12.162: W/System.err(3950): at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:174) java
解決方法是設置下httpurlconnection的請求屬性 ui
HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection(); url
if (Build.VERSION.SDK != null && Build.VERSION.SDK_INT > 13) {
conn.setRequestProperty("Connection", "close"); //sdk3.2以後用這個
}else{
conn.setRequestProperty("http.keepAlive", "false"); // sdk2.2以前用這個
} spa