Apache HttpClient 5.5 includes a SOCKS configuration path on the connection manager's socket settings. Its maintained example uses setSocksProxyAddress:

InetSocketAddress socks =
    new InetSocketAddress("proxy.example.net", 1080);

PoolingHttpClientConnectionManager manager =
    PoolingHttpClientConnectionManagerBuilder.create()
        .setDefaultSocketConfig(
            SocketConfig.custom()
                .setSocksProxyAddress(socks)
                .build()
        )
        .build();

CloseableHttpClient client = HttpClients.custom()
    .setConnectionManager(manager)
    .build();

The fragment uses HttpClient 5's org.apache.hc packages and HttpCore's SocketConfig. Requests made with this client use the pool configured above. Close the client when the application's ownership scope ends.

Put the actual website URL on the request as usual. For permitted public-site requests without proxy authentication, the SOCKS proxy list offers candidate addresses; choose a SOCKS version supported by the actual runtime. The SOCKS address configures the transport used to reach it; it is not an HTTP forward-proxy route supplied as an HttpHost.

These are default socket settings for this manager. An application using a per-route SocketConfig resolver should apply the desired SOCKS setting through that policy instead. The example retains the connection manager's normal destination DNS policy; remote name resolution requires a separately verified configuration.

Mikanda mikatakata