Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Alvarez committed May 13, 2024
1 parent 147a882 commit da6f0e6
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ public static ProxySelector createProxySelector(ProxyConfiguration proxyConfig)
InetSocketAddress address = createInetSocketAddress(defaultEnvProxy);
return fixedProxySelectorFor(new Proxy(Proxy.Type.HTTP, address));
case HTTP:
return getHttpProxySelector(proxyConfig);
return getHttpProxySelector(proxyConfig, false);
case HTTPS:
return getHttpProxySelector(proxyConfig);
return getHttpProxySelector(proxyConfig, true);
case MESH:
return ProxySelector.getDefault(); // MESH proxy is not a Java proxy
case SOCKS:
Expand Down Expand Up @@ -216,16 +216,16 @@ private static Optional<HostAndPort> meshProxy(Optional<ProxyConfiguration> prox
}
}

private static ProxySelector getHttpProxySelector(ProxyConfiguration proxyConfig) {
private static ProxySelector getHttpProxySelector(ProxyConfiguration proxyConfig, boolean https) {
HostAndPort httpsHostAndPort = HostAndPort.fromString(proxyConfig
.hostAndPort()
.orElseThrow(() -> new SafeIllegalArgumentException(
"Expected to find proxy hostAndPort configuration for HTTP(S) proxy")));
InetSocketAddress httpsAddress =
InetSocketAddress address =
// Proxy address must not be resolved, otherwise DNS changes while the application
// is running are ignored by the application.
InetSocketAddress.createUnresolved(httpsHostAndPort.getHost(), httpsHostAndPort.getPort());
return fixedProxySelectorFor(HttpsProxies.create(httpsAddress));
return fixedProxySelectorFor(https ? HttpsProxies.create(address) : new Proxy(Proxy.Type.HTTP, address));
}

private static ProxySelector fixedProxySelectorFor(Proxy proxy) {
Expand Down

0 comments on commit da6f0e6

Please sign in to comment.