HttpURLConnection exposes usingProxy, but the result needs the connection’s implementation and state beside it. It is not a test request.

In OpenJDK 25’s HTTP handler, an explicitly configured HTTP proxy can make the method return true before the network connection is opened:

import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URI;

var proxy = new Proxy(Proxy.Type.HTTP,
    new InetSocketAddress("proxy.example", 8080));
var url = URI.create("http://example.com/").toURL();
var connection = (HttpURLConnection) url.openConnection(proxy);
boolean proxyFlag = connection.usingProxy();

An HTTP candidate from the HTTP proxy list can fill the host and port for an allowed public request without proxy authentication. openConnection constructs the object. It does not establish the HTTP connection merely by returning that object. The flag in this explicit-proxy case therefore does not prove that the intermediary is reachable or accepts the request.

With automatic selection, route choice can happen later as the handler connects. An early false result should not be treated as the final route decision. After connection, interpret the state together with any exception or response, particularly when authentication or fallback was involved.

The public method belongs to HttpURLConnection, while the behavior above is specific to the named OpenJDK handler. Another provider or JDK implementation need not expose identical pre-connection details.

Record how the proxy was selected and when the flag was read. To establish the source address seen by the destination, retain destination-side evidence; a boolean proxy marker has no field for that exit address.

Erthyglow kevrennek