com.squareup.okhttp.Route#com.squareup.okhttp.Connection源码实例Demo

下面列出了com.squareup.okhttp.Route#com.squareup.okhttp.Connection 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: crosswalk-cordova-android   文件: HttpEngine.java
/**
 * @param requestHeaders the client's supplied request headers. This class
 *     creates a private copy that it can mutate.
 * @param connection the connection used for an intermediate response
 *     immediately prior to this request/response pair, such as a same-host
 *     redirect. This engine assumes ownership of the connection and must
 *     release it when it is unneeded.
 */
public HttpEngine(OkHttpClient client, Policy policy, String method, RawHeaders requestHeaders,
    Connection connection, RetryableOutputStream requestBodyOut) throws IOException {
  this.client = client;
  this.policy = policy;
  this.method = method;
  this.connection = connection;
  this.requestBodyOut = requestBodyOut;

  try {
    uri = Platform.get().toUriLenient(policy.getURL());
  } catch (URISyntaxException e) {
    throw new IOException(e.getMessage());
  }

  this.requestHeaders = new RequestHeaders(uri, new RawHeaders(requestHeaders));
}
 
源代码2 项目: L.TileLayer.Cordova   文件: HttpEngine.java
/**
 * @param requestHeaders the client's supplied request headers. This class
 *     creates a private copy that it can mutate.
 * @param connection the connection used for an intermediate response
 *     immediately prior to this request/response pair, such as a same-host
 *     redirect. This engine assumes ownership of the connection and must
 *     release it when it is unneeded.
 */
public HttpEngine(OkHttpClient client, Policy policy, String method, RawHeaders requestHeaders,
    Connection connection, RetryableOutputStream requestBodyOut) throws IOException {
  this.client = client;
  this.policy = policy;
  this.method = method;
  this.connection = connection;
  this.requestBodyOut = requestBodyOut;

  try {
    uri = Platform.get().toUriLenient(policy.getURL());
  } catch (URISyntaxException e) {
    throw new IOException(e.getMessage());
  }

  this.requestHeaders = new RequestHeaders(uri, new RawHeaders(requestHeaders));
}
 
源代码3 项目: wildfly-samples   文件: HttpEngine.java
/**
 * @param requestHeaders the client's supplied request headers. This class
 *     creates a private copy that it can mutate.
 * @param connection the connection used for an intermediate response
 *     immediately prior to this request/response pair, such as a same-host
 *     redirect. This engine assumes ownership of the connection and must
 *     release it when it is unneeded.
 */
public HttpEngine(OkHttpClient client, Policy policy, String method, RawHeaders requestHeaders,
    Connection connection, RetryableOutputStream requestBodyOut) throws IOException {
  this.client = client;
  this.policy = policy;
  this.method = method;
  this.connection = connection;
  this.requestBodyOut = requestBodyOut;

  try {
    uri = Platform.get().toUriLenient(policy.getURL());
  } catch (URISyntaxException e) {
    throw new IOException(e.getMessage());
  }

  this.requestHeaders = new RequestHeaders(uri, new RawHeaders(requestHeaders));
}
 
源代码4 项目: L.TileLayer.Cordova   文件: HttpTransport.java
/**
 * Discards the response body so that the connection can be reused. This
 * needs to be done judiciously, since it delays the current request in
 * order to speed up a potential future request that may never occur.
 *
 * <p>A stream may be discarded to encourage response caching (a response
 * cannot be cached unless it is consumed completely) or to enable connection
 * reuse.
 */
private static boolean discardStream(HttpEngine httpEngine, InputStream responseBodyIn) {
  Connection connection = httpEngine.connection;
  if (connection == null) return false;
  Socket socket = connection.getSocket();
  if (socket == null) return false;
  try {
    int socketTimeout = socket.getSoTimeout();
    socket.setSoTimeout(DISCARD_STREAM_TIMEOUT_MILLIS);
    try {
      Util.skipAll(responseBodyIn);
      return true;
    } finally {
      socket.setSoTimeout(socketTimeout);
    }
  } catch (IOException e) {
    return false;
  }
}
 
源代码5 项目: IoTgo_Android_App   文件: HttpTransport.java
/**
 * Discards the response body so that the connection can be reused. This
 * needs to be done judiciously, since it delays the current request in
 * order to speed up a potential future request that may never occur.
 *
 * <p>A stream may be discarded to encourage response caching (a response
 * cannot be cached unless it is consumed completely) or to enable connection
 * reuse.
 */
private static boolean discardStream(HttpEngine httpEngine, InputStream responseBodyIn) {
  Connection connection = httpEngine.connection;
  if (connection == null) return false;
  Socket socket = connection.getSocket();
  if (socket == null) return false;
  try {
    int socketTimeout = socket.getSoTimeout();
    socket.setSoTimeout(DISCARD_STREAM_TIMEOUT_MILLIS);
    try {
      Util.skipAll(responseBodyIn);
      return true;
    } finally {
      socket.setSoTimeout(socketTimeout);
    }
  } catch (IOException e) {
    return false;
  }
}
 
源代码6 项目: wildfly-samples   文件: HttpTransport.java
/**
 * Discards the response body so that the connection can be reused. This
 * needs to be done judiciously, since it delays the current request in
 * order to speed up a potential future request that may never occur.
 *
 * <p>A stream may be discarded to encourage response caching (a response
 * cannot be cached unless it is consumed completely) or to enable connection
 * reuse.
 */
private static boolean discardStream(HttpEngine httpEngine, InputStream responseBodyIn) {
  Connection connection = httpEngine.connection;
  if (connection == null) return false;
  Socket socket = connection.getSocket();
  if (socket == null) return false;
  try {
    int socketTimeout = socket.getSoTimeout();
    socket.setSoTimeout(DISCARD_STREAM_TIMEOUT_MILLIS);
    try {
      Util.skipAll(responseBodyIn);
      return true;
    } finally {
      socket.setSoTimeout(socketTimeout);
    }
  } catch (IOException e) {
    return false;
  }
}
 
源代码7 项目: phonegapbootcampsite   文件: HttpTransport.java
/**
 * Discards the response body so that the connection can be reused. This
 * needs to be done judiciously, since it delays the current request in
 * order to speed up a potential future request that may never occur.
 *
 * <p>A stream may be discarded to encourage response caching (a response
 * cannot be cached unless it is consumed completely) or to enable connection
 * reuse.
 */
private static boolean discardStream(HttpEngine httpEngine, InputStream responseBodyIn) {
  Connection connection = httpEngine.connection;
  if (connection == null) return false;
  Socket socket = connection.getSocket();
  if (socket == null) return false;
  try {
    int socketTimeout = socket.getSoTimeout();
    socket.setSoTimeout(DISCARD_STREAM_TIMEOUT_MILLIS);
    try {
      Util.skipAll(responseBodyIn);
      return true;
    } finally {
      socket.setSoTimeout(socketTimeout);
    }
  } catch (IOException e) {
    return false;
  }
}
 
源代码8 项目: android-discourse   文件: HttpTransport.java
/**
 * Discards the response body so that the connection can be reused. This
 * needs to be done judiciously, since it delays the current request in
 * order to speed up a potential future request that may never occur.
 * <p/>
 * <p>A stream may be discarded to encourage response caching (a response
 * cannot be cached unless it is consumed completely) or to enable connection
 * reuse.
 */
private static boolean discardStream(HttpEngine httpEngine, InputStream responseBodyIn) {
    Connection connection = httpEngine.connection;
    if (connection == null)
        return false;
    Socket socket = connection.getSocket();
    if (socket == null)
        return false;
    try {
        int socketTimeout = socket.getSoTimeout();
        socket.setSoTimeout(DISCARD_STREAM_TIMEOUT_MILLIS);
        try {
            Util.skipAll(responseBodyIn);
            return true;
        } finally {
            socket.setSoTimeout(socketTimeout);
        }
    } catch (IOException e) {
        return false;
    }
}
 
源代码9 项目: bluemix-parking-meter   文件: HttpEngine.java
/**
 * @param requestHeaders the client's supplied request headers. This class
 *     creates a private copy that it can mutate.
 * @param connection the connection used for an intermediate response
 *     immediately prior to this request/response pair, such as a same-host
 *     redirect. This engine assumes ownership of the connection and must
 *     release it when it is unneeded.
 */
public HttpEngine(OkHttpClient client, Policy policy, String method, RawHeaders requestHeaders,
    Connection connection, RetryableOutputStream requestBodyOut) throws IOException {
  this.client = client;
  this.policy = policy;
  this.method = method;
  this.connection = connection;
  this.requestBodyOut = requestBodyOut;

  try {
    uri = Platform.get().toUriLenient(policy.getURL());
  } catch (URISyntaxException e) {
    throw new IOException(e.getMessage());
  }

  this.requestHeaders = new RequestHeaders(uri, new RawHeaders(requestHeaders));
}
 
/**
 * Discards the response body so that the connection can be reused. This
 * needs to be done judiciously, since it delays the current request in
 * order to speed up a potential future request that may never occur.
 */
private static boolean discardStream(HttpEngine httpEngine, InputStream responseBodyIn) {
  Connection connection = httpEngine.connection;
  if (connection == null) return false;
  Socket socket = connection.getSocket();
  if (socket == null) return false;
  try {
    int socketTimeout = socket.getSoTimeout();
    socket.setSoTimeout(DISCARD_STREAM_TIMEOUT_MILLIS);
    try {
      Util.skipAll(responseBodyIn);
      return true;
    } finally {
      socket.setSoTimeout(socketTimeout);
    }
  } catch (IOException e) {
    return false;
  }
}
 
源代码11 项目: bluemix-parking-meter   文件: HttpTransport.java
/**
 * Discards the response body so that the connection can be reused. This
 * needs to be done judiciously, since it delays the current request in
 * order to speed up a potential future request that may never occur.
 *
 * <p>A stream may be discarded to encourage response caching (a response
 * cannot be cached unless it is consumed completely) or to enable connection
 * reuse.
 */
private static boolean discardStream(HttpEngine httpEngine, InputStream responseBodyIn) {
  Connection connection = httpEngine.connection;
  if (connection == null) return false;
  Socket socket = connection.getSocket();
  if (socket == null) return false;
  try {
    int socketTimeout = socket.getSoTimeout();
    socket.setSoTimeout(DISCARD_STREAM_TIMEOUT_MILLIS);
    try {
      Util.skipAll(responseBodyIn);
      return true;
    } finally {
      socket.setSoTimeout(socketTimeout);
    }
  } catch (IOException e) {
    return false;
  }
}
 
源代码12 项目: cordova-android-chromeview   文件: HttpEngine.java
/**
 * @param requestHeaders the client's supplied request headers. This class
 * creates a private copy that it can mutate.
 * @param connection the connection used for an intermediate response
 * immediately prior to this request/response pair, such as a same-host
 * redirect. This engine assumes ownership of the connection and must
 * release it when it is unneeded.
 */
public HttpEngine(HttpURLConnectionImpl policy, String method, RawHeaders requestHeaders,
    Connection connection, RetryableOutputStream requestBodyOut) throws IOException {
  this.policy = policy;
  this.method = method;
  this.connection = connection;
  this.requestBodyOut = requestBodyOut;

  try {
    uri = Platform.get().toUriLenient(policy.getURL());
  } catch (URISyntaxException e) {
    throw new IOException(e.getMessage());
  }

  this.requestHeaders = new RequestHeaders(uri, new RawHeaders(requestHeaders));
}
 
源代码13 项目: CordovaYoutubeVideoPlayer   文件: HttpTransport.java
/**
 * Discards the response body so that the connection can be reused. This
 * needs to be done judiciously, since it delays the current request in
 * order to speed up a potential future request that may never occur.
 *
 * <p>A stream may be discarded to encourage response caching (a response
 * cannot be cached unless it is consumed completely) or to enable connection
 * reuse.
 */
private static boolean discardStream(HttpEngine httpEngine, InputStream responseBodyIn) {
  Connection connection = httpEngine.connection;
  if (connection == null) return false;
  Socket socket = connection.getSocket();
  if (socket == null) return false;
  try {
    int socketTimeout = socket.getSoTimeout();
    socket.setSoTimeout(DISCARD_STREAM_TIMEOUT_MILLIS);
    try {
      Util.skipAll(responseBodyIn);
      return true;
    } finally {
      socket.setSoTimeout(socketTimeout);
    }
  } catch (IOException e) {
    return false;
  }
}
 
源代码14 项目: crosswalk-cordova-android   文件: HttpTransport.java
/**
 * Discards the response body so that the connection can be reused. This
 * needs to be done judiciously, since it delays the current request in
 * order to speed up a potential future request that may never occur.
 *
 * <p>A stream may be discarded to encourage response caching (a response
 * cannot be cached unless it is consumed completely) or to enable connection
 * reuse.
 */
private static boolean discardStream(HttpEngine httpEngine, InputStream responseBodyIn) {
  Connection connection = httpEngine.connection;
  if (connection == null) return false;
  Socket socket = connection.getSocket();
  if (socket == null) return false;
  try {
    int socketTimeout = socket.getSoTimeout();
    socket.setSoTimeout(DISCARD_STREAM_TIMEOUT_MILLIS);
    try {
      Util.skipAll(responseBodyIn);
      return true;
    } finally {
      socket.setSoTimeout(socketTimeout);
    }
  } catch (IOException e) {
    return false;
  }
}
 
源代码15 项目: cordova-android-chromeview   文件: HttpTransport.java
/**
 * Discards the response body so that the connection can be reused. This
 * needs to be done judiciously, since it delays the current request in
 * order to speed up a potential future request that may never occur.
 */
private static boolean discardStream(HttpEngine httpEngine, InputStream responseBodyIn) {
  Connection connection = httpEngine.connection;
  if (connection == null) return false;
  Socket socket = connection.getSocket();
  if (socket == null) return false;
  try {
    int socketTimeout = socket.getSoTimeout();
    socket.setSoTimeout(DISCARD_STREAM_TIMEOUT_MILLIS);
    try {
      Util.skipAll(responseBodyIn);
      return true;
    } finally {
      socket.setSoTimeout(socketTimeout);
    }
  } catch (IOException e) {
    return false;
  }
}
 
源代码16 项目: phonegapbootcampsite   文件: HttpEngine.java
/**
 * @param requestHeaders the client's supplied request headers. This class
 *     creates a private copy that it can mutate.
 * @param connection the connection used for an intermediate response
 *     immediately prior to this request/response pair, such as a same-host
 *     redirect. This engine assumes ownership of the connection and must
 *     release it when it is unneeded.
 */
public HttpEngine(OkHttpClient client, Policy policy, String method, RawHeaders requestHeaders,
    Connection connection, RetryableOutputStream requestBodyOut) throws IOException {
  this.client = client;
  this.policy = policy;
  this.method = method;
  this.connection = connection;
  this.requestBodyOut = requestBodyOut;

  try {
    uri = Platform.get().toUriLenient(policy.getURL());
  } catch (URISyntaxException e) {
    throw new IOException(e.getMessage());
  }

  this.requestHeaders = new RequestHeaders(uri, new RawHeaders(requestHeaders));
}
 
源代码17 项目: weex   文件: OkHttpInterceptor.java
public OkHttpInspectorResponse(
    String requestId,
    Request request,
    Response response,
    Connection connection) {
  mRequestId = requestId;
  mRequest = request;
  mResponse = response;
  mConnection = connection;
}
 
源代码18 项目: stetho   文件: StethoInterceptor.java
public OkHttpInspectorResponse(
    String requestId,
    Request request,
    Response response,
    Connection connection) {
  mRequestId = requestId;
  mRequest = request;
  mResponse = response;
  mConnection = connection;
}
 
源代码19 项目: 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);
}
 
源代码20 项目: 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);
}
 
源代码21 项目: 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);
}
 
源代码22 项目: 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);
}
 
源代码23 项目: wildfly-samples   文件: HttpURLConnectionImpl.java
private HttpEngine newHttpEngine(String method, RawHeaders requestHeaders,
    Connection connection, RetryableOutputStream requestBody) throws IOException {
  if (url.getProtocol().equals("http")) {
    return new HttpEngine(client, this, method, requestHeaders, connection, requestBody);
  } else if (url.getProtocol().equals("https")) {
    return new HttpsEngine(client, this, method, requestHeaders, connection, requestBody);
  } else {
    throw new AssertionError();
  }
}
 
private HttpEngine newHttpEngine(String method, RawHeaders requestHeaders,
    Connection connection, RetryableOutputStream requestBody) throws IOException {
  if (url.getProtocol().equals("http")) {
    return new HttpEngine(this, method, requestHeaders, connection, requestBody);
  } else if (url.getProtocol().equals("https")) {
    return new HttpsURLConnectionImpl.HttpsEngine(
        this, method, requestHeaders, connection, requestBody);
  } else {
    throw new AssertionError();
  }
}
 
源代码25 项目: 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);
}
 
源代码26 项目: 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);
}
 
源代码27 项目: 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);
}
 
源代码28 项目: cordova-android-chromeview   文件: 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);
  }

  failedRoutes.add(failedRoute);
  if (!(failure instanceof SSLHandshakeException)) {
    // If the problem was not related to SSL then it will also fail with
    // a different Tls mode therefore we can be proactive about it.
    failedRoutes.add(failedRoute.flipTlsMode());
  }
}
 
private HttpEngine newHttpEngine(String method, RawHeaders requestHeaders,
    Connection connection, RetryableOutputStream requestBody) throws IOException {
  if (url.getProtocol().equals("http")) {
    return new HttpEngine(client, this, method, requestHeaders, connection, requestBody);
  } else if (url.getProtocol().equals("https")) {
    return new HttpsEngine(client, this, method, requestHeaders, connection, requestBody);
  } else {
    throw new AssertionError();
  }
}
 
源代码30 项目: 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);
}