Package org.deftserver.web.http.client

Examples of org.deftserver.web.http.client.AsynchronousHttpClient


 
  @Test
  public void asynchronousHttpClientTransferEncodingChunkedTest() throws InterruptedException {
    final CountDownLatch latch = new CountDownLatch(1);
    final String url = "http://localhost:" + PORT + "/chunked";
    final AsynchronousHttpClient http = new AsynchronousHttpClient();
    final AsyncResult<org.deftserver.web.http.client.Response> cb =
      new AsyncResult<org.deftserver.web.http.client.Response>() {

      public void onSuccess(org.deftserver.web.http.client.Response response) {
        if (response.getBody().equals("arogerab") &&
          response.getHeader("Transfer-Encoding").equals("chunked"))
        {
          latch.countDown();
        }
      }
     
      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());   
  }
View Full Code Here


import org.deftserver.web.http.client.Response;

public class AsynchronousHttpClientExample {

  public static void main(String[] args) {
    AsynchronousHttpClient client = new AsynchronousHttpClient();
    client.fetch("http://sunet.se/",
        new AsyncResult<Response>() {
          public void onFailure(Throwable caught) { out.println("exception:\n" + caught);}
          public void onSuccess(Response response) { out.println("http resonse:\n" + response);}
        }
    );
View Full Code Here

TOP

Related Classes of org.deftserver.web.http.client.AsynchronousHttpClient

Copyright © 2018 www.massapicom. 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.