Package org.apache.http.impl.nio.client

Examples of org.apache.http.impl.nio.client.CloseableHttpAsyncClient.execute()


            System.out.println("Executing request " + httpget.getRequestLine());

            httpclient.start();

            // Pass local context as a parameter
            Future<HttpResponse> future = httpclient.execute(httpget, localContext, null);

            // Please note that it may be unsafe to access HttpContext instance
            // while the request is still being executed

            HttpResponse response = future.get();
View Full Code Here


                    new HttpGet("https://www.verisign.com/"),
                    new HttpGet("http://www.google.com/")
            };
            final CountDownLatch latch = new CountDownLatch(requests.length);
            for (final HttpGet request: requests) {
                httpclient.execute(request, new FutureCallback<HttpResponse>() {

                    public void completed(final HttpResponse response) {
                        latch.countDown();
                        System.out.println(request.getRequestLine() + "->" + response.getStatusLine());
                    }
View Full Code Here

    public static void main(final String[] args) throws Exception {
        CloseableHttpAsyncClient httpclient = HttpAsyncClients.createDefault();
        try {
            httpclient.start();
            Future<Boolean> future = httpclient.execute(
                    HttpAsyncMethods.createGet("http://localhost:8080/"),
                    new MyResponseConsumer(), null);
            Boolean result = future.get();
            if (result != null && result.booleanValue()) {
                System.out.println("Request successfully executed");
View Full Code Here

        CloseableHttpAsyncClient httpclient = HttpAsyncClients.createDefault();
        try {
            httpclient.start();
            URI url = new URI(webServer.getUri() + "/");
            HttpPost request = new HttpPost(url);
            httpclient.execute(request, null);
            latch2.await();

        } finally {
            httpclient.close();
        }
View Full Code Here

          requests[i] = new HttpGet(ARTICLELIST_URL_STRING + "/start:" + i*100);
        }
        final CountDownLatch latch = new CountDownLatch(requests.length);
        stringBuilder.append("<ol>");
        for (final HttpGet request: requests) {
          httpclient.execute(request, new FutureCallback<HttpResponse>() {
            public void completed(final HttpResponse response) {
              BasicResponseHandler handler = new BasicResponseHandler();
              latch.countDown();
              stringBuilder.append("<li>" + request.getRequestLine() + "->" + response.getStatusLine() + "</li>");
              System.out.println(request.getRequestLine() + "->" + response.getStatusLine());
View Full Code Here

          requests[i] = new HttpGet(ARTICLELIST_URL_STRING + "/start:" + i*100);
        }
        final CountDownLatch latch = new CountDownLatch(requests.length);
        // stringBuilder.append("<ol>");
        for (final HttpGet request: requests) {
          httpclient.execute(request, new FutureCallback<HttpResponse>() {
            public void completed(final HttpResponse response) {
              BasicResponseHandler handler = new BasicResponseHandler();
              try {
                extract(handler.handleResponse(response));
              } catch (Exception e)  {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.