private HttpClientBuilder getHttpClientBuilder(final HttpExecutionRequest execution) {
        val requestConfig = RequestConfig.custom();
        requestConfig.setConnectTimeout(CONNECT_TIMEOUT_IN_MILLISECONDS);
        requestConfig.setConnectionRequestTimeout(CONNECTION_REQUEST_TIMEOUT_IN_MILLISECONDS);

        val builder = HttpClientBuilder
            .create()
            .useSystemProperties()
            .setDefaultRequestConfig(requestConfig.build());
        if (execution.getMaximumRetryAttempts() <= 1) {
            builder.disableAutomaticRetries();
        }
        val socketFactory = Optional.ofNullable(execution.getHttpClient())
            .map(HttpClient::httpClientFactory)
            .filter(factory -> Objects.nonNull(factory.getSslSocketFactory()))
            .map(HttpClientFactory::getSslSocketFactory)
            .orElseGet(() -> getSslConnectionSocketFactory(execution));

        val connectionManager = PoolingHttpClientConnectionManagerBuilder.create()
            .setSSLSocketFactory(socketFactory)
            .setDefaultSocketConfig(SocketConfig.custom()
                .setSoTimeout(SOCKET_TIMEOUT_IN_MILLISECONDS)
                .build())
            .setPoolConcurrencyPolicy(PoolConcurrencyPolicy.STRICT)
            .setConnPoolPolicy(PoolReusePolicy.LIFO)
            .setDefaultConnectionConfig(ConnectionConfig.custom()
                .setTimeToLive(CONNECT_TTL_TIMEOUT_IN_MILLISECONDS)
                .setSocketTimeout(SOCKET_TIMEOUT_IN_MILLISECONDS)
                .setConnectTimeout(CONNECT_TIMEOUT_IN_MILLISECONDS)
                .build())
            .build();
        builder.setConnectionManager(connectionManager);
        return builder;
    }
Prepare http request. Tries to set the authorization header
in cases where the URL endpoint does not actually produce the header
on its own.

@param request   the request
@param execution the execution request
core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/http/HttpUtils.java