@Override
    public void process(final HttpRequest request, final EntityDetails entity, final HttpContext context)
            throws HttpException, IOException {
        Args.notNull(request, "HTTP request");

        final String method = request.getMethod();
        if (Method.CONNECT.isSame(method)) {
            return;
        }

        final HttpClientContext clientContext = HttpClientContext.cast(context);
        final String exchangeId = clientContext.getExchangeId();

        // Obtain the client connection (required)
        final RouteInfo route = clientContext.getHttpRoute();
        if (route == null) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("{} Connection route not set in the context", exchangeId);
            }
            return;
        }

        if (route.getHopCount() == 1 || route.isTunnelled()) {
            if (!request.containsHeader(HttpHeaders.CONNECTION)) {
                request.addHeader(HttpHeaders.CONNECTION, HeaderElements.KEEP_ALIVE);
            }
        }
    }
This protocol interceptor is responsible for adding the {@code Connection}
header to the outgoing requests, which is essential for managing persistence
of {@code HTTP/1.0} connections.

@since 4.0
httpclient5/src/main/java/org/apache/hc/client5/http/protocol/RequestClientConnControl.java