代码如下:
var config = Dsl.config();
var proxy = Dsl.proxyServer("10.1.2.3", 1081);
proxy.setProxyType(ProxyType.SOCKS_V5);
config.setProxyServer(proxy); // Set default proxy globally
var client = Dsl.asyncHttpClient(config);
client
.prepareGet("https://httpstat.us/200")
.execute()
.toCompletableFuture()
.thenAccept(r -> System.out.println("with proxy: " + r.getResponseBody()))
.join();
client
.prepareGet("https://httpstat.us/200")
.setProxyServer((ProxyServer) null) // I expected it will disable proxy for this particular request
.execute()
.toCompletableFuture()
.thenAccept(r -> System.out.println("without proxy: " + r.getResponseBody()))
.join();
我原以为第二个请求会在没有代理的情况下执行。
暂无答案!
目前还没有任何答案,快来回答吧!