开发者

java httpclient detect server disconnect

开发者 https://www.devze.com 2023-03-18 22:30 出处:网络
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,

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

精彩评论

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