private Optional<Response> followFailoverHistory(String httpMethod, URL url, Request request)
      throws IOException {
    Preconditions.checkArgument(isHttpsProtocol(url));
    switch (failoverHistory.getOrDefault(url.getHost() + ":" + url.getPort(), Failover.NONE)) {
      case HTTP:
        return Optional.of(call(httpMethod, toHttp(url), request, getHttpTransport(true), true));
      case INSECURE_HTTPS:
        return Optional.of(call(httpMethod, url, request, getHttpTransport(false), true));
      default:
        return Optional.empty(); // No history found. Should go for normal execution path.
    }
  }
Sends the request.

@param httpMethod the HTTP request method
@param url endpoint URL
@param request the request to send
@return the response to the sent request
@throws IOException if building the HTTP request fails.
jib-core/src/main/java/com/google/cloud/tools/jib/http/FailoverHttpClient.java