类com.squareup.okhttp.Route源码实例Demo

下面列出了怎么用com.squareup.okhttp.Route的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: L.TileLayer.Cordova   文件: RouteSelector.java
public RouteSelector(Address address, URI uri, ProxySelector proxySelector, ConnectionPool pool,
    Dns dns, RouteDatabase routeDatabase) {
  this.address = address;
  this.uri = uri;
  this.proxySelector = proxySelector;
  this.pool = pool;
  this.dns = dns;
  this.routeDatabase = routeDatabase;
  this.postponedRoutes = new LinkedList<Route>();

  resetNextProxy(uri, address.getProxy());
}
 
源代码2 项目: L.TileLayer.Cordova   文件: RouteSelector.java
/**
 * Returns the next route address to attempt.
 *
 * @throws NoSuchElementException if there are no more routes to attempt.
 */
public Connection next(String method) throws IOException {
  // Always prefer pooled connections over new connections.
  for (Connection pooled; (pooled = pool.get(address)) != null; ) {
    if (method.equals("GET") || pooled.isReadable()) return pooled;
    pooled.close();
  }

  // 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 (routeDatabase.shouldPostpone(route)) {
    postponedRoutes.add(route);
    // We will only recurse in order to skip previously failed routes. They will be
    // tried last.
    return next(method);
  }

  return new Connection(route);
}
 
源代码3 项目: L.TileLayer.Cordova   文件: RouteSelector.java
/**
 * Clients should invoke this method when they encounter a connectivity
 * failure on a connection returned by this route selector.
 */
public void connectFailed(Connection connection, IOException failure) {
  Route failedRoute = connection.getRoute();
  if (failedRoute.getProxy().type() != Proxy.Type.DIRECT && proxySelector != null) {
    // Tell the proxy selector when we fail to connect on a fresh connection.
    proxySelector.connectFailed(uri, failedRoute.getProxy().address(), failure);
  }

  routeDatabase.failed(failedRoute, failure);
}
 
源代码4 项目: IoTgo_Android_App   文件: RouteSelector.java
public RouteSelector(Address address, URI uri, ProxySelector proxySelector, ConnectionPool pool,
    Dns dns, RouteDatabase routeDatabase) {
  this.address = address;
  this.uri = uri;
  this.proxySelector = proxySelector;
  this.pool = pool;
  this.dns = dns;
  this.routeDatabase = routeDatabase;
  this.postponedRoutes = new LinkedList<Route>();

  resetNextProxy(uri, address.getProxy());
}
 
源代码5 项目: IoTgo_Android_App   文件: RouteSelector.java
/**
 * Returns the next route address to attempt.
 *
 * @throws NoSuchElementException if there are no more routes to attempt.
 */
public Connection next(String method) throws IOException {
  // Always prefer pooled connections over new connections.
  for (Connection pooled; (pooled = pool.get(address)) != null; ) {
    if (method.equals("GET") || pooled.isReadable()) return pooled;
    pooled.close();
  }

  // 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 (routeDatabase.shouldPostpone(route)) {
    postponedRoutes.add(route);
    // We will only recurse in order to skip previously failed routes. They will be
    // tried last.
    return next(method);
  }

  return new Connection(route);
}
 
源代码6 项目: IoTgo_Android_App   文件: RouteSelector.java
/**
 * Clients should invoke this method when they encounter a connectivity
 * failure on a connection returned by this route selector.
 */
public void connectFailed(Connection connection, IOException failure) {
  Route failedRoute = connection.getRoute();
  if (failedRoute.getProxy().type() != Proxy.Type.DIRECT && proxySelector != null) {
    // Tell the proxy selector when we fail to connect on a fresh connection.
    proxySelector.connectFailed(uri, failedRoute.getProxy().address(), failure);
  }

  routeDatabase.failed(failedRoute, failure);
}
 
源代码7 项目: android-discourse   文件: RouteSelector.java
public RouteSelector(Address address, URI uri, ProxySelector proxySelector, ConnectionPool pool, Dns dns, RouteDatabase routeDatabase) {
    this.address = address;
    this.uri = uri;
    this.proxySelector = proxySelector;
    this.pool = pool;
    this.dns = dns;
    this.routeDatabase = routeDatabase;
    this.postponedRoutes = new LinkedList<Route>();

    resetNextProxy(uri, address.getProxy());
}
 
源代码8 项目: android-discourse   文件: RouteSelector.java
/**
 * Returns the next route address to attempt.
 *
 * @throws NoSuchElementException if there are no more routes to attempt.
 */
public Connection next(String method) throws IOException {
    // Always prefer pooled connections over new connections.
    for (Connection pooled; (pooled = pool.get(address)) != null; ) {
        if (method.equals("GET") || pooled.isReadable())
            return pooled;
        pooled.close();
    }

    // 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 (routeDatabase.shouldPostpone(route)) {
        postponedRoutes.add(route);
        // We will only recurse in order to skip previously failed routes. They will be
        // tried last.
        return next(method);
    }

    return new Connection(route);
}
 
源代码9 项目: android-discourse   文件: RouteSelector.java
/**
 * Clients should invoke this method when they encounter a connectivity
 * failure on a connection returned by this route selector.
 */
public void connectFailed(Connection connection, IOException failure) {
    Route failedRoute = connection.getRoute();
    if (failedRoute.getProxy().type() != Proxy.Type.DIRECT && proxySelector != null) {
        // Tell the proxy selector when we fail to connect on a fresh connection.
        proxySelector.connectFailed(uri, failedRoute.getProxy().address(), failure);
    }

    routeDatabase.failed(failedRoute, failure);
}
 
源代码10 项目: bluemix-parking-meter   文件: RouteSelector.java
public RouteSelector(Address address, URI uri, ProxySelector proxySelector, ConnectionPool pool,
    Dns dns, RouteDatabase routeDatabase) {
  this.address = address;
  this.uri = uri;
  this.proxySelector = proxySelector;
  this.pool = pool;
  this.dns = dns;
  this.routeDatabase = routeDatabase;
  this.postponedRoutes = new LinkedList<Route>();

  resetNextProxy(uri, address.getProxy());
}
 
源代码11 项目: bluemix-parking-meter   文件: RouteSelector.java
/**
 * Returns the next route address to attempt.
 *
 * @throws NoSuchElementException if there are no more routes to attempt.
 */
public Connection next(String method) throws IOException {
  // Always prefer pooled connections over new connections.
  for (Connection pooled; (pooled = pool.get(address)) != null; ) {
    if (method.equals("GET") || pooled.isReadable()) return pooled;
    pooled.close();
  }

  // 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 (routeDatabase.shouldPostpone(route)) {
    postponedRoutes.add(route);
    // We will only recurse in order to skip previously failed routes. They will be
    // tried last.
    return next(method);
  }

  return new Connection(route);
}
 
源代码12 项目: bluemix-parking-meter   文件: RouteSelector.java
/**
 * Clients should invoke this method when they encounter a connectivity
 * failure on a connection returned by this route selector.
 */
public void connectFailed(Connection connection, IOException failure) {
  Route failedRoute = connection.getRoute();
  if (failedRoute.getProxy().type() != Proxy.Type.DIRECT && proxySelector != null) {
    // Tell the proxy selector when we fail to connect on a fresh connection.
    proxySelector.connectFailed(uri, failedRoute.getProxy().address(), failure);
  }

  routeDatabase.failed(failedRoute, failure);
}
 
源代码13 项目: reader   文件: RouteSelector.java
public RouteSelector(Address address, URI uri, ProxySelector proxySelector, ConnectionPool pool,
    Dns dns, RouteDatabase routeDatabase) {
  this.address = address;
  this.uri = uri;
  this.proxySelector = proxySelector;
  this.pool = pool;
  this.dns = dns;
  this.routeDatabase = routeDatabase;
  this.postponedRoutes = new LinkedList<Route>();

  resetNextProxy(uri, address.getProxy());
}
 
源代码14 项目: reader   文件: RouteSelector.java
/**
 * Returns the next route address to attempt.
 *
 * @throws NoSuchElementException if there are no more routes to attempt.
 */
public Connection next(String method) throws IOException {
  // Always prefer pooled connections over new connections.
  for (Connection pooled; (pooled = pool.get(address)) != null; ) {
    if (method.equals("GET") || pooled.isReadable()) return pooled;
    pooled.close();
  }

  // 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 (routeDatabase.shouldPostpone(route)) {
    postponedRoutes.add(route);
    // We will only recurse in order to skip previously failed routes. They will be
    // tried last.
    return next(method);
  }

  return new Connection(route);
}
 
源代码15 项目: reader   文件: RouteSelector.java
/**
 * Clients should invoke this method when they encounter a connectivity
 * failure on a connection returned by this route selector.
 */
public void connectFailed(Connection connection, IOException failure) {
  Route failedRoute = connection.getRoute();
  if (failedRoute.getProxy().type() != Proxy.Type.DIRECT && proxySelector != null) {
    // Tell the proxy selector when we fail to connect on a fresh connection.
    proxySelector.connectFailed(uri, failedRoute.getProxy().address(), failure);
  }

  routeDatabase.failed(failedRoute, failure);
}
 
源代码16 项目: reader   文件: RouteSelector.java
public RouteSelector(Address address, URI uri, ProxySelector proxySelector, ConnectionPool pool,
    Dns dns, RouteDatabase routeDatabase) {
  this.address = address;
  this.uri = uri;
  this.proxySelector = proxySelector;
  this.pool = pool;
  this.dns = dns;
  this.routeDatabase = routeDatabase;
  this.postponedRoutes = new LinkedList<Route>();

  resetNextProxy(uri, address.getProxy());
}
 
源代码17 项目: reader   文件: RouteSelector.java
/**
 * Returns the next route address to attempt.
 *
 * @throws NoSuchElementException if there are no more routes to attempt.
 */
public Connection next(String method) throws IOException {
  // Always prefer pooled connections over new connections.
  for (Connection pooled; (pooled = pool.get(address)) != null; ) {
    if (method.equals("GET") || pooled.isReadable()) return pooled;
    pooled.close();
  }

  // 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 (routeDatabase.shouldPostpone(route)) {
    postponedRoutes.add(route);
    // We will only recurse in order to skip previously failed routes. They will be
    // tried last.
    return next(method);
  }

  return new Connection(route);
}
 
源代码18 项目: reader   文件: RouteSelector.java
/**
 * Clients should invoke this method when they encounter a connectivity
 * failure on a connection returned by this route selector.
 */
public void connectFailed(Connection connection, IOException failure) {
  Route failedRoute = connection.getRoute();
  if (failedRoute.getProxy().type() != Proxy.Type.DIRECT && proxySelector != null) {
    // Tell the proxy selector when we fail to connect on a fresh connection.
    proxySelector.connectFailed(uri, failedRoute.getProxy().address(), failure);
  }

  routeDatabase.failed(failedRoute, failure);
}
 
源代码19 项目: cordova-amazon-fireos   文件: RouteSelector.java
public RouteSelector(Address address, URI uri, ProxySelector proxySelector, ConnectionPool pool,
    Dns dns, RouteDatabase routeDatabase) {
  this.address = address;
  this.uri = uri;
  this.proxySelector = proxySelector;
  this.pool = pool;
  this.dns = dns;
  this.routeDatabase = routeDatabase;
  this.postponedRoutes = new LinkedList<Route>();

  resetNextProxy(uri, address.getProxy());
}
 
源代码20 项目: cordova-amazon-fireos   文件: RouteSelector.java
/**
 * Returns the next route address to attempt.
 *
 * @throws NoSuchElementException if there are no more routes to attempt.
 */
public Connection next(String method) throws IOException {
  // Always prefer pooled connections over new connections.
  for (Connection pooled; (pooled = pool.get(address)) != null; ) {
    if (method.equals("GET") || pooled.isReadable()) return pooled;
    pooled.close();
  }

  // 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 (routeDatabase.shouldPostpone(route)) {
    postponedRoutes.add(route);
    // We will only recurse in order to skip previously failed routes. They will be
    // tried last.
    return next(method);
  }

  return new Connection(route);
}
 
源代码21 项目: cordova-amazon-fireos   文件: RouteSelector.java
/**
 * Clients should invoke this method when they encounter a connectivity
 * failure on a connection returned by this route selector.
 */
public void connectFailed(Connection connection, IOException failure) {
  Route failedRoute = connection.getRoute();
  if (failedRoute.getProxy().type() != Proxy.Type.DIRECT && proxySelector != null) {
    // Tell the proxy selector when we fail to connect on a fresh connection.
    proxySelector.connectFailed(uri, failedRoute.getProxy().address(), failure);
  }

  routeDatabase.failed(failedRoute, failure);
}
 
源代码22 项目: phonegapbootcampsite   文件: RouteSelector.java
public RouteSelector(Address address, URI uri, ProxySelector proxySelector, ConnectionPool pool,
    Dns dns, RouteDatabase routeDatabase) {
  this.address = address;
  this.uri = uri;
  this.proxySelector = proxySelector;
  this.pool = pool;
  this.dns = dns;
  this.routeDatabase = routeDatabase;
  this.postponedRoutes = new LinkedList<Route>();

  resetNextProxy(uri, address.getProxy());
}
 
源代码23 项目: phonegapbootcampsite   文件: RouteSelector.java
/**
 * Returns the next route address to attempt.
 *
 * @throws NoSuchElementException if there are no more routes to attempt.
 */
public Connection next(String method) throws IOException {
  // Always prefer pooled connections over new connections.
  for (Connection pooled; (pooled = pool.get(address)) != null; ) {
    if (method.equals("GET") || pooled.isReadable()) return pooled;
    pooled.close();
  }

  // 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 (routeDatabase.shouldPostpone(route)) {
    postponedRoutes.add(route);
    // We will only recurse in order to skip previously failed routes. They will be
    // tried last.
    return next(method);
  }

  return new Connection(route);
}
 
源代码24 项目: phonegapbootcampsite   文件: RouteSelector.java
/**
 * Clients should invoke this method when they encounter a connectivity
 * failure on a connection returned by this route selector.
 */
public void connectFailed(Connection connection, IOException failure) {
  Route failedRoute = connection.getRoute();
  if (failedRoute.getProxy().type() != Proxy.Type.DIRECT && proxySelector != null) {
    // Tell the proxy selector when we fail to connect on a fresh connection.
    proxySelector.connectFailed(uri, failedRoute.getProxy().address(), failure);
  }

  routeDatabase.failed(failedRoute, failure);
}
 
源代码25 项目: CordovaYoutubeVideoPlayer   文件: RouteSelector.java
public RouteSelector(Address address, URI uri, ProxySelector proxySelector, ConnectionPool pool,
    Dns dns, RouteDatabase routeDatabase) {
  this.address = address;
  this.uri = uri;
  this.proxySelector = proxySelector;
  this.pool = pool;
  this.dns = dns;
  this.routeDatabase = routeDatabase;
  this.postponedRoutes = new LinkedList<Route>();

  resetNextProxy(uri, address.getProxy());
}
 
源代码26 项目: CordovaYoutubeVideoPlayer   文件: RouteSelector.java
/**
 * Returns the next route address to attempt.
 *
 * @throws NoSuchElementException if there are no more routes to attempt.
 */
public Connection next(String method) throws IOException {
  // Always prefer pooled connections over new connections.
  for (Connection pooled; (pooled = pool.get(address)) != null; ) {
    if (method.equals("GET") || pooled.isReadable()) return pooled;
    pooled.close();
  }

  // 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 (routeDatabase.shouldPostpone(route)) {
    postponedRoutes.add(route);
    // We will only recurse in order to skip previously failed routes. They will be
    // tried last.
    return next(method);
  }

  return new Connection(route);
}
 
源代码27 项目: CordovaYoutubeVideoPlayer   文件: RouteSelector.java
/**
 * Clients should invoke this method when they encounter a connectivity
 * failure on a connection returned by this route selector.
 */
public void connectFailed(Connection connection, IOException failure) {
  Route failedRoute = connection.getRoute();
  if (failedRoute.getProxy().type() != Proxy.Type.DIRECT && proxySelector != null) {
    // Tell the proxy selector when we fail to connect on a fresh connection.
    proxySelector.connectFailed(uri, failedRoute.getProxy().address(), failure);
  }

  routeDatabase.failed(failedRoute, failure);
}
 
public HttpURLConnectionImpl(URL url, OkHttpClient client, OkResponseCache responseCache,
    Set<Route> failedRoutes) {
  super(url);
  this.followProtocolRedirects = client.getFollowProtocolRedirects();
  this.failedRoutes = failedRoutes;
  this.requestedProxy = client.getProxy();
  this.proxySelector = client.getProxySelector();
  this.cookieHandler = client.getCookieHandler();
  this.connectionPool = client.getConnectionPool();
  this.sslSocketFactory = client.getSslSocketFactory();
  this.hostnameVerifier = client.getHostnameVerifier();
  this.responseCache = responseCache;
}
 
源代码29 项目: cordova-android-chromeview   文件: RouteSelector.java
public RouteSelector(Address address, URI uri, ProxySelector proxySelector, ConnectionPool pool,
    Dns dns, Set<Route> failedRoutes) {
  this.address = address;
  this.uri = uri;
  this.proxySelector = proxySelector;
  this.pool = pool;
  this.dns = dns;
  this.failedRoutes = failedRoutes;
  this.postponedRoutes = new LinkedList<Route>();

  resetNextProxy(uri, address.getProxy());
}
 
源代码30 项目: cordova-android-chromeview   文件: RouteSelector.java
/**
 * 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);
    // We will only recurse in order to skip previously failed routes. They will be
    // tried last.
    return next();
  }

  return new Connection(route);
}
 
 类所在包
 同包方法