public static void main(final String[] args) throws Exception { CloseableHttpPipeliningClient httpclient = HttpAsyncClients.createPipelining(); try { httpclient.start(); HttpHost targetHost = new HttpHost("localhost", 8080); HttpGet[] resquests = { new HttpGet("/docs/index.html"), new HttpGet("/docs/introduction.html"), new HttpGet("/docs/setup.html"), new HttpGet("/docs/config/index.html") }; Future<List<HttpResponse>> future = httpclient.execute(targetHost, Arrays.<HttpRequest>asList(resquests), null); List<HttpResponse> responses = future.get(); System.out.println(responses); System.out.println("Shutting down"); } finally { httpclient.close(); } System.out.println("Done"); }
public static void main(final String[] args) throws Exception { CloseableHttpPipeliningClient httpclient = HttpAsyncClients.createPipelining(); try { httpclient.start(); HttpHost targetHost = new HttpHost("localhost", 8080); HttpGet[] resquests = { new HttpGet("/docs/index.html"), new HttpGet("/docs/introduction.html"), new HttpGet("/docs/setup.html"), new HttpGet("/docs/config/index.html") }; List<MyRequestProducer> requestProducers = new ArrayList<MyRequestProducer>(); List<MyResponseConsumer> responseConsumers = new ArrayList<MyResponseConsumer>(); for (HttpGet request : resquests) { requestProducers.add(new MyRequestProducer(targetHost, request)); responseConsumers.add(new MyResponseConsumer(request)); } Future<List<Boolean>> future = httpclient.execute(targetHost, requestProducers, responseConsumers, null); future.get(); System.out.println("Shutting down"); } finally { httpclient.close(); } System.out.println("Done"); }
public static void main(final String[] args) throws Exception { CloseableHttpPipeliningClient httpclient = HttpAsyncClients.createPipelining(); try { httpclient.start(); HttpHost targetHost = new HttpHost("localhost", 8080); HttpGet[] resquests = { new HttpGet("/docs/index.html"), new HttpGet("/docs/introduction.html"), new HttpGet("/docs/setup.html"), new HttpGet("/docs/config/index.html") }; List<MyRequestProducer> requestProducers = new ArrayList<MyRequestProducer>(); List<MyResponseConsumer> responseConsumers = new ArrayList<MyResponseConsumer>(); for (HttpGet request: resquests) { requestProducers.add(new MyRequestProducer(targetHost, request)); responseConsumers.add(new MyResponseConsumer(request)); } Future<List<Boolean>> future = httpclient.execute( targetHost, requestProducers, responseConsumers, null); future.get(); System.out.println("Shutting down"); } finally { httpclient.close(); } System.out.println("Done"); }
public CloseableHttpPipeliningClient getClient() { return httpClient; }