private boolean needAuthentication(
            final AuthExchange proxyAuthExchange,
            final HttpHost proxy,
            final HttpResponse response,
            final HttpClientContext context) throws AuthenticationException, MalformedChallengeException {
        final RequestConfig config = context.getRequestConfigOrDefault();
        if (config.isAuthenticationEnabled()) {
            final boolean proxyAuthRequested = authenticator.isChallenged(proxy, ChallengeType.PROXY, response, proxyAuthExchange, context);
            final boolean proxyMutualAuthRequired = authenticator.isChallengeExpected(proxyAuthExchange);

            if (authCacheKeeper != null) {
                if (proxyAuthRequested) {
                    authCacheKeeper.updateOnChallenge(proxy, null, proxyAuthExchange, context);
                } else {
                    authCacheKeeper.updateOnNoChallenge(proxy, null, proxyAuthExchange, context);
                }
            }

            if (proxyAuthRequested || proxyMutualAuthRequired) {
                final boolean updated = authenticator.handleResponse(proxy, ChallengeType.PROXY, response,
                        proxyAuthStrategy, proxyAuthExchange, context);

                if (authCacheKeeper != null) {
                    authCacheKeeper.updateOnResponse(proxy, null, proxyAuthExchange, context);
                }

                return updated;
            }
        }
        return false;
    }
Request execution handler in the asynchronous request execution chain
that is responsible for establishing connection to the target
origin server as specified by the current connection route.

@since 5.0
httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncConnectExec.java