开发者

java httpclient detect server disconnect

I'm doing a GET request with the apache HttpClient. Is there a way to detect when the serv开发者_JS百科er disconnects while reading from the InputStream?


EOS on the input stream (read() returning -1, readLine() returning null, readXXX() throwing EOFException for any other XXX) is the primary mechanism, otherwise an IOException, typically 'connection reset'. Very rarely you may see a SocketException. If you are using read timeouts, a SocketTimeoutException.


Sure, check out the Exception Handling section of the docs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜