Github user ok2c commented on the issue:

    https://github.com/apache/httpcomponents-client/pull/100
  
    @kirill-usov It most definitely works with minimal HttpAsyncClient
    ```
    final IOReactorConfig ioReactorConfig = IOReactorConfig.custom()
            .setSoTimeout(Timeout.ofSeconds(5))
            .build();
    
    final MinimalHttpAsyncClient client = HttpAsyncClients.createMinimal(
            HttpVersionPolicy.NEGOTIATE,
            H2Config.DEFAULT,
            H1Config.DEFAULT,
            ioReactorConfig);
    
    client.start();
    
    final URI requestUri = new URI("http://httpbin.org/get";);
    final HttpHost target = new HttpHost(
            requestUri.getHost(),
            requestUri.getPort() > 0 ? requestUri.getPort() : 80,
            requestUri.getScheme());
    final Future<AsyncClientEndpoint> leaseFuture = client.lease(target, null);
    final AsyncClientEndpoint endpoint = leaseFuture.get(30, TimeUnit.SECONDS);
    try {
    
        final CountDownLatch latch = new CountDownLatch(1);
        endpoint.execute(new BasicClientExchangeHandler<SimpleHttpResponse>(
                                 
SimpleRequestProducer.create(SimpleHttpRequest.get(requestUri)),
                                 SimpleResponseConsumer.create(),
                                 new FutureCallback<SimpleHttpResponse>() {
    
                                     @Override
                                     public void completed(final 
SimpleHttpResponse response) {
                                         latch.countDown();
                                         System.out.println(requestUri + "->" + 
response.getCode());
                                     }
    
                                     @Override
                                     public void failed(final Exception ex) {
                                         latch.countDown();
                                         System.out.println(requestUri + "->" + 
ex);
                                     }
    
                                     @Override
                                     public void cancelled() {
                                         latch.countDown();
                                         System.out.println(requestUri + " 
cancelled");
                                     }
    
                                 }) {
    
                             @Override
                             public void consumeInformation(final HttpResponse 
response) throws HttpException, IOException {
                                 System.out.println("infornation response:" + 
response);
                             }
    
                         },
                HttpClientContext.create());
    
        latch.await();
    } finally {
        endpoint.releaseAndReuse();
    }
    
    System.out.println("Shutting down");
    client.shutdown(ShutdownType.GRACEFUL);
    ```


---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to