HttpClient httpClient = new HttpClientBuilder(environment).build("httpClient");
Request request = httpClient.get("http://example.com/api/resource");
request.header("Content-Type", "application/json");
Response response = request.send();
HttpClient httpClient = new HttpClientBuilder(environment).build("httpClient");
Request request1 = httpClient.get("http://example.com/api/resource1");
Request request2 = httpClient.get("http://example.com/api/resource2");
ListenableFuture<Response> future1 = request1.sendAsync();
ListenableFuture<Response> future2 = request2.sendAsync();
ListenableFuture<List<Response>> combinedFuture = Futures.allAsList(future1, future2);
List<Response> responses = combinedFuture.get();
yaml
httpClient:
timeout:
connect: 5000
read: 5000
write: 5000
pool:
maxConnections: 100
maxConnectionsPerRoute: 20