http超时重发机制
下面是主要代码
HttpRequestRetryHandler myRetryHandler = new HttpRequestRetryHandler() {
@Override
public boolean retryRequest(IOException exception, int arg1, HttpContext arg2) {
if (arg1 >= 3) {
return false;
}
if (exception instanceof InterruptedIOException) {
// Timeout
return true;
}
if (exception instanceof UnknownHostException) {
// Unknown host
return true;
}
if (exception instanceof ConnectTimeoutException) {
// Connection refused
return true;
}
if (exception instanceof SocketTimeoutException) {
// Connection refused
return true;
}
if (ex