Keep the real resource URL and pass the proxy separately to URLConnection:

URI destination = URI.create("https://example.com/report");
Proxy proxy = new Proxy(Proxy.Type.HTTP,
    new InetSocketAddress("203.0.113.10", 8080));
URLConnection connection = destination.toURL().openConnection(proxy);
connection.setConnectTimeout(5000);
connection.setReadTimeout(10000);

Use the java.net imports and replace the documentation proxy address with your HTTP service or a candidate from the HTTP proxy list. The connection still requests https://example.com/report; the proxy is its route. This setup configures neither credentials nor every HTTP library in the JVM.

Wrong code that substitutes the proxy into the resource URL can get a quick proxy web page or error instead of the report. Compare status, content and actual destination before interpreting that quick response as better performance.

openConnection(Proxy) leaves the resource path on the destination URI. Keep that hostname for HTTPS certificate verification too; changing it to the intermediary can add a name mismatch to the routing error.

If the application constructs another HTTP client, use that client or its connection-factory interface. A URLConnection proxy object cannot configure a path that never calls this API.

Artiglyn mynjee