private static void addProxyConfiguration(FeedClientBuilderImpl b, HttpClient httpClient) throws IOException {
        Origin.Address address = new Origin.Address(b.proxy.getHost(), b.proxy.getPort());
        Map<String, Supplier<String>> proxyHeadersCopy = new TreeMap<>(b.proxyRequestHeaders);
        if (b.proxy.getScheme().equals("https")) {
            SslContextFactory.Client proxySslCtxFactory = new SslContextFactory.Client();
            if (b.proxyHostnameVerifier != null) {
                proxySslCtxFactory.setHostnameVerifier(b.proxyHostnameVerifier);
                // Disable built-in hostname verification in the JDK's TLS implementation
                proxySslCtxFactory.setEndpointIdentificationAlgorithm(null);
            }
            proxySslCtxFactory.setSslContext(b.constructProxySslContext());
            try { proxySslCtxFactory.start(); } catch (Exception e) { throw new IOException(e); }
            httpClient.getProxyConfiguration().addProxy(
                    new HttpProxy(address, proxySslCtxFactory, new Origin.Protocol(List.of("h2"), false)));
            URI proxyUri = URI.create(endpointUri(b.proxy));
            httpClient.getAuthenticationStore().addAuthenticationResult(new Authentication.Result() {
                @Override public URI getURI() { return proxyUri; }
                @Override public void apply(Request r) {
                    r.headers(hs -> proxyHeadersCopy.forEach((k, v) -> hs.add(k, v.get())));
                }
            });
        } else {
            // Assume insecure proxy uses HTTP/1.1
            httpClient.getProxyConfiguration().addProxy(
                    new HttpProxy(address, false, new Origin.Protocol(List.of("http/1.1"), false)));
            // Bug in Jetty cause authentication result to be ignored for HTTP/1.1 CONNECT requests
            httpClient.getRequestListeners().addHeadersListener(new Request.Listener() {
                @Override
                public void onHeaders(Request r) {
                    if (HttpMethod.CONNECT.is(r.getMethod()))
                        r.headers(hs -> proxyHeadersCopy.forEach((k, v) -> hs.add(k, v.get())));
                }
            });
        }
    }
Client implementation based on Jetty HTTP Client

@author bjorncs
vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/JettyCluster.java