Package org.xlightweb.client

Examples of org.xlightweb.client.HttpClientConnection.call()


      Server server = new Server(dh);
      server.start();
     
     
      HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
      IHttpResponse response = con.call(new GetRequest("/"));
      System.out.println(response);
     
      response.getBlockingBody().readString();
      server.close();     
  }
View Full Code Here


      server.start();
     
     
      HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
     
      IHttpResponse response = con.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/"));
      Assert.assertEquals(200, response.getStatus());
      Assert.assertEquals("12345", response.getBody().readString());
     
        response = con.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/"));
        Assert.assertEquals(200, response.getStatus());
View Full Code Here

    con.setIdleTimeoutMillis(500);
   
    GetRequest request = new GetRequest("/");
    request.setHeader("sleep-time", Integer.toString(1000));
    try {
      con.call(request);
      Assert.fail("SocketTimeoutException expected");
    } catch (IOException expected) { }
   
    con.close();
    server.close();
View Full Code Here

    server.start();
 
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
    con.setBodyDataReceiveTimeoutMillis(1000);

    IHttpResponse response = con.call(new GetRequest("/?loops=3&waittime=200"));
    response.getBlockingBody().readString();
   
    response = con.call(new GetRequest("/?loops=1&waittime=2000"));
   
    try {
View Full Code Here

    con.setBodyDataReceiveTimeoutMillis(1000);

    IHttpResponse response = con.call(new GetRequest("/?loops=3&waittime=200"));
    response.getBlockingBody().readString();
   
    response = con.call(new GetRequest("/?loops=1&waittime=2000"));
   
    try {
      response.getBlockingBody().readString();
      Assert.fail("ReceiveTimeoutException expected");
    } catch (ReceiveTimeoutException expected) { }
View Full Code Here

   
    HttpServer server = new HttpServer(new RequestHandler());
    server.start();
   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
    IHttpResponse response = con.call(new GetRequest("/"));
   
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals("it works", response.getBody().toString());
 
    Assert.assertTrue(con.isOpen());
View Full Code Here

    server.start();
   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
   
    for (int i = 0; i < 10; i++) {
      IHttpResponse response = con.call(new GetRequest("/"));
     
      Assert.assertEquals(200, response.getStatus());
      Assert.assertEquals("it works", response.getBody().toString());
   
      Assert.assertTrue(con.isOpen());
View Full Code Here

   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());

    GetRequest request = new GetRequest("/");
    request.setHeader("Connection", "close");
    IHttpResponse response = con.call(request);
     
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals("it works", response.getBody().toString());
   
    QAUtil.sleep(500);
View Full Code Here

    Assert.assertFalse(con.isOpen());

   
    request = new GetRequest("/");
    try {
      con.call(request);
      Assert.fail("ClosedChannelException expected");
    } catch (ClosedChannelException expected) { }

    con.close();
    server.close();
View Full Code Here

   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
    GetRequest req = new GetRequest("/");
    req.setHeader("Connection", "close");
   
    IHttpResponse response = con.call(req);
   
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals("it works", response.getBody().toString());
 
    QAUtil.sleep(500);
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.