问题描述
- java.net.SocketException: socket closed
-
返回的httpresponse 内容如下
HTTP/1.1 200 OK [Server: zhihu_nginx, Date: Sun, 29 Sep 2013 02:08:35 GMT, Content-Type: application/json, Transfer-Encoding: chunked, Connection: keep-alive, Vary: Accept-Encoding, Expires: Fri, 02 Jan 2000 00:00:00 GMT, Pragma: no-cache, Cache-Control: private, no-store, max-age=0,no-cache, must-revalidate, post-check=0, pre-check=0]报错如下:
Exception in thread "main" java.net.SocketException: socket closed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:136)
at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:152)
at org.apache.http.impl.io.SessionInputBufferImpl.read(SessionInputBufferImpl.java:203)
at org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:174)
at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:137)
at java.util.zip.InflaterInputStream.fill(Unknown Source)
at java.util.zip.InflaterInputStream.read(Unknown Source)
at java.util.zip.GZIPInputStream.read(Unknown Source)
at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)
at sun.nio.cs.StreamDecoder.implRead(Unknown Source)
at sun.nio.cs.StreamDecoder.read(Unknown Source)
at java.io.InputStreamReader.read(Unknown Source)
at java.io.Reader.read(Unknown Source)
at org.apache.http.util.EntityUtils.toString(EntityUtils.java:244)
at org.apache.http.util.EntityUtils.toString(EntityUtils.java:288)
at zhihu.ZhihuDownload.getAnswersList(ZhihuDownload.java:138)
at zhihu.ZhihuDownload.main(ZhihuDownload.java:54)