Class RouteDatabase

java.lang.Object
com.squareup.okhttp.RouteDatabase

public final class RouteDatabase
extends Object
A blacklist of failed routes to avoid when creating a new connection to a target address. This is used so that OkHttp can learn from its mistakes: if there was a failure attempting to connect to a specific IP address, proxy server or TLS mode, that failure is remembered and alternate routes are preferred.
  • Constructor Details

    • RouteDatabase

      public RouteDatabase()
  • Method Details

    • failed

      public void failed​(Route failedRoute, IOException failure)
      Records a failure connecting to failedRoute.
    • connected

      public void connected​(Route route)
      Records success connecting to failedRoute.
    • shouldPostpone

      public boolean shouldPostpone​(Route route)
      Returns true if route has failed recently and should be avoided.
    • failedRoutesCount

      public int failedRoutesCount()