var client = HttpClient.newBuilder()
.version(HttpClient.Version.HTTP_2)
.followRedirects(HttpClient.Redirect.NORMAL)
.connectTimeout(Duration.ofSeconds(5))
.proxy(ProxySelector.of(new InetSocketAddress("127.0.0.1", 10800)))
.executor(Executors.newVirtualThreadPerTaskExecutor())
.build();
var request = HttpRequest.newBuilder()
.uri(URI.create("
https://www.baidu.com/"))
.timeout(Duration.ofMinutes(2))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString("{}"))
.build();
client.sendAsync(request, HttpResponse.BodyHandlers.ofString()).thenAccept(System.out::println);