Package org.deftserver.web.http.client

Examples of org.deftserver.web.http.client.AsynchronousHttpClient.fetch()


public class AsynchronousHttpClientExample {

  public static void main(String[] args) {
    AsynchronousHttpClient client = new AsynchronousHttpClient();
    client.fetch("http://tt.se/start/", new ResultCallback());
    IOLoop.INSTANCE.start();
  }
 
  private static class ResultCallback implements AsyncResult<HttpResponse> {
View Full Code Here


    final CountDownLatch latch = new CountDownLatch(1);
    final AsynchronousHttpClient client = new AsynchronousHttpClient();
    final AsyncCallback runByIOLoop = new AsyncCallback() {

      public void onCallback() {
        client.fetch(unresolvableAddress, new AsyncResult<org.deftserver.web.http.client.HttpResponse>() {

          public void onSuccess(org.deftserver.web.http.client.HttpResponse result) { client.close(); }

          public void onFailure(Throwable caught) {
            if (caught instanceof UnresolvedAddressException) latch.countDown();
View Full Code Here

    final CountDownLatch latch = new CountDownLatch(1);
    final AsynchronousHttpClient client = new AsynchronousHttpClient();
    final AsyncCallback runByIOLoop = new AsyncCallback() {

      public void onCallback() {
        client.fetch(unconnectableAddress, new AsyncResult<org.deftserver.web.http.client.HttpResponse>() {

          public void onSuccess(org.deftserver.web.http.client.HttpResponse result) { client.close(); }

          public void onFailure(Throwable caught) {
            if (caught instanceof ConnectException) latch.countDown();
View Full Code Here

        }

        public void onFailure(Throwable ignore) { }
      };
      // make sure that the http.fetch(..) is invoked from the ioloop thread
      IOLoop.INSTANCE.addCallback(new AsyncCallback() { public void onCallback() { http.fetch(url, cb); }});
      latch.await(5, TimeUnit.SECONDS);
      assertEquals(0, latch.getCount());
      assertEquals("hello test", result[0]);
      assertEquals("HTTP/1.1 200 OK", result[1]);
    }
View Full Code Here

      public void onSuccess(org.deftserver.web.http.client.HttpResponse response) { }

      public void onFailure(Throwable e) { if (e instanceof ConnectException) latch.countDown(); }
    };
    // make sure that the http.fetch(..) is invoked from the ioloop thread
    IOLoop.INSTANCE.addCallback(new AsyncCallback() { public void onCallback() { http.fetch(url, cb); }});
    latch.await(5, TimeUnit.SECONDS);
    assertEquals(0, latch.getCount());
  }
 
 
View Full Code Here

    final CountDownLatch latch = new CountDownLatch(1);
    final AsynchronousHttpClient client = new AsynchronousHttpClient();
    final AsyncCallback runByIOLoop = new AsyncCallback() {

      public void onCallback() {
        client.fetch(unresolvableAddress, new AsyncResult<org.deftserver.web.http.client.Response>() {

          public void onSuccess(org.deftserver.web.http.client.Response result) { client.close(); }

          public void onFailure(Throwable caught) {
            if (caught instanceof UnresolvedAddressException) latch.countDown();
View Full Code Here

    final CountDownLatch latch = new CountDownLatch(1);
    final AsynchronousHttpClient client = new AsynchronousHttpClient();
    final AsyncCallback runByIOLoop = new AsyncCallback() {

      public void onCallback() {
        client.fetch(unconnectableAddress, new AsyncResult<org.deftserver.web.http.client.Response>() {

          public void onSuccess(org.deftserver.web.http.client.Response result) { client.close(); }

          public void onFailure(Throwable caught) {
            if (caught instanceof ConnectException) latch.countDown();
View Full Code Here

        }

        public void onFailure(Throwable ignore) { }
      };
      // make sure that the http.fetch(..) is invoked from the ioloop thread
      IOLoop.INSTANCE.addCallback(new AsyncCallback() { public void onCallback() { http.fetch(url, cb); }});
      latch.await(15, TimeUnit.SECONDS);
      assertEquals(0, latch.getCount());
      assertEquals("hello test", result[0]);
      assertEquals("HTTP/1.1 200 OK", result[1]);
    }
View Full Code Here

      public void onSuccess(org.deftserver.web.http.client.Response response) { }

      public void onFailure(Throwable e) { if (e instanceof ConnectException) latch.countDown(); }
    };
    // make sure that the http.fetch(..) is invoked from the ioloop thread
    IOLoop.INSTANCE.addCallback(new AsyncCallback() { public void onCallback() { http.fetch(url, cb); }});
    latch.await(5, TimeUnit.SECONDS);
    assertEquals(0, latch.getCount());
  }
 
  @Test
View Full Code Here

     
      public void onFailure(Throwable e) { }
   
    };
    // make sure that the http.fetch(..) is invoked from the ioloop thread
    IOLoop.INSTANCE.addCallback(new AsyncCallback() { public void onCallback() { http.fetch(url, cb); }});
    latch.await(5, TimeUnit.SECONDS);
    assertEquals(0, latch.getCount());
  }
 
  @Test
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.