private static void addProxy(ClientConfig cc, Config config) { if (config.getProxy() != null) { HttpUrlConnectorProvider cp = new HttpUrlConnectorProvider(); cc.connectorProvider(cp); final Proxy proxy = new Proxy(Type.HTTP, new InetSocketAddress(config.getProxy().getRawHost(), config.getProxy().getPort())); cp.connectionFactory(new ConnectionFactory() { @Override public HttpURLConnection getConnection(URL url) throws IOException { return (HttpURLConnection) url.openConnection(proxy); }}); } }