In previous versions of HttpClient target host was set up into client itself. In last version (for HttpAsyncClient it's 4.1.1) host is set up into HttpRequest (HttpGet, HttpPost etc.) every time I do a request.
I want to use persistent connection, so I use HttpAsyncClient. I create and use it like this:
CloseableHttpAsyncClient client = HttpAsyncClients.createDefault();
client.start();
List<Future<HttpResponse>> responses = new ArrayList<>();
for (int i = 0; i < 10; i++)
{
HttpGet get = new HttpGet("https://google.com/");
responses.add(client.execute(get, null));
}
for (Future<HttpResponse> response : responses) {
response.get(); //wait for the response
}
As I tested, it works faster than usual HttpClient (if I do all the requests, and then wait for all the responses).
But I can't fully understand, how it works inside. How many connections with https://google.com/ are established? What happens if I use client for one host, and then for another? (as I tested, responses can come in any order, so I suppose there are at least 2 connections in parallel). What's the difference between HttpAsyncClients.createDefault() and HttpAsyncClients.createPipelining() ?
Thanks!