use of com.squareup.okhttp.Route in project cordova-android-chromeview by thedracle.
the class RouteSelector method next.
/**
* Returns the next route address to attempt.
*
* @throws NoSuchElementException if there are no more routes to attempt.
*/
public Connection next() throws IOException {
// Always prefer pooled connections over new connections.
Connection pooled = pool.get(address);
if (pooled != null) {
return pooled;
}
// Compute the next route to attempt.
if (!hasNextTlsMode()) {
if (!hasNextInetSocketAddress()) {
if (!hasNextProxy()) {
if (!hasNextPostponed()) {
throw new NoSuchElementException();
}
return new Connection(nextPostponed());
}
lastProxy = nextProxy();
resetNextInetSocketAddress(lastProxy);
}
lastInetSocketAddress = nextInetSocketAddress();
resetNextTlsMode();
}
boolean modernTls = nextTlsMode() == TLS_MODE_MODERN;
Route route = new Route(address, lastProxy, lastInetSocketAddress, modernTls);
if (failedRoutes.contains(route)) {
postponedRoutes.add(route);
// tried last.
return next();
}
return new Connection(route);
}
Aggregations