/** * The code below is copied from http-remoting and should be removed when we switch the clients to use remoting. */ public static ProxySelector createProxySelector(ProxyConfiguration proxyConfig) { switch (proxyConfig.type()) { case DIRECT: return fixedProxySelectorFor(Proxy.NO_PROXY); case HTTP: HostAndPort hostAndPort = HostAndPort.fromString(proxyConfig.hostAndPort() .orElseThrow(() -> new IllegalArgumentException( "Expected to find proxy hostAndPort configuration for HTTP proxy"))); InetSocketAddress addr = new InetSocketAddress(hostAndPort.getHost(), hostAndPort.getPort()); return fixedProxySelectorFor(new Proxy(Proxy.Type.HTTP, addr)); default: // fall through } throw new IllegalStateException("Failed to create ProxySelector for proxy configuration: " + proxyConfig); }
private static Optional<HostAndPort> meshProxy(Optional<ProxyConfiguration> proxy) { if (proxy.isPresent() && proxy.get().type() == ProxyConfiguration.Type.MESH) { return Optional.of(HostAndPort.fromString(proxy.get().hostAndPort().get())); } else { return Optional.empty(); } }
/** * The code below is copied from http-remoting and should be removed when we switch the clients to use remoting. */ public static ProxySelector createProxySelector(ProxyConfiguration proxyConfig) { switch (proxyConfig.type()) { case DIRECT: return fixedProxySelectorFor(Proxy.NO_PROXY); case HTTP: HostAndPort hostAndPort = HostAndPort.fromString(proxyConfig.hostAndPort() .orElseThrow(() -> new IllegalArgumentException( "Expected to find proxy hostAndPort configuration for HTTP proxy"))); InetSocketAddress addr = new InetSocketAddress(hostAndPort.getHost(), hostAndPort.getPort()); return fixedProxySelectorFor(new Proxy(Proxy.Type.HTTP, addr)); default: // fall through } throw new IllegalStateException("Failed to create ProxySelector for proxy configuration: " + proxyConfig); }
public static ProxySelector createProxySelector(ProxyConfiguration proxyConfig) { switch (proxyConfig.type()) { case DIRECT: return fixedProxySelectorFor(Proxy.NO_PROXY); case HTTP: HostAndPort hostAndPort = HostAndPort.fromString(proxyConfig.hostAndPort() .orElseThrow(() -> new IllegalArgumentException( "Expected to find proxy hostAndPort configuration for HTTP proxy"))); InetSocketAddress addr = new InetSocketAddress(hostAndPort.getHost(), hostAndPort.getPort()); return fixedProxySelectorFor(new Proxy(Proxy.Type.HTTP, addr)); case MESH: return ProxySelector.getDefault(); // MESH proxy is not a Java proxy default: // fall through } throw new IllegalStateException("Failed to create ProxySelector for proxy configuration: " + proxyConfig); }