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)解决方法是设置下httpurlconnection的请求属性
HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
if (Build.VERSION.SDK != null && Build.VERSION.SDK_INT > 13) {
conn.setRequestProperty("Connection", "close"); //sdk3.2之后用这个 }else{ conn.setRequestProperty("http.keepAlive", "false"); // sdk2.2之前用这个 }