private boolean exitAfterHandlingConnect( //
      final Channel channel, //
      final NettyResponseFuture<?> future, //
      final Request request, //
      ProxyServer proxyServer, //
      int statusCode, //
      HttpRequest httpRequest)
      throws IOException {

    if (future.isKeepAlive()) future.attachChannel(channel, true);

    Uri requestUri = request.getUri();
    logger.debug("Connecting to proxy {} for scheme {}", proxyServer, requestUri.getScheme());

    channelManager.upgradeProtocol(channel.pipeline(), requestUri);
    future.setReuseChannel(true);
    future.setConnectAllowed(false);
    requestSender.drainChannelAndExecuteNextRequest(
        channel, future, new RequestBuilder(future.getTargetRequest()).build());

    return true;
  }
  private boolean handleHttpResponse(
      final HttpResponse response,
      final Channel channel,
      final NettyResponseFuture<?> future,
      AsyncHandler<?> handler)
      throws Exception {

    HttpRequest httpRequest = future.getNettyRequest().getHttpRequest();
    logger.debug("\n\nRequest {}\n\nResponse {}\n", httpRequest, response);

    future.setKeepAlive(
        config.getKeepAliveStrategy().keepAlive(future.getTargetRequest(), httpRequest, response));

    NettyResponseStatus status =
        new NettyResponseStatus(future.getUri(), config, response, channel);
    HttpResponseHeaders responseHeaders = new HttpResponseHeaders(response.headers());

    return exitAfterProcessingFilters(channel, future, handler, status, responseHeaders)
        || //
        exitAfterSpecialCases(response, channel, future)
        || //
        exitAfterHandler(channel, future, response, handler, status, httpRequest, responseHeaders);
  }