Package org.xlightweb.client

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


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


   
    HttpServer server = new HttpServer(new RequestHandler2());
    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

   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
   
    for (int i = 0; i < 5; i++) {
      HttpRequest request = new HttpRequest("HEAD", "/");
      IHttpResponse response = con.call(request);
     
      Assert.assertEquals(200, response.getStatus());
    }
 
   
View Full Code Here

   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
   
    for (int i = 0; i < 5; i++) {
      HttpRequest request = new HttpRequest("TRACE", "/");
      IHttpResponse response = con.call(request);
      String body = response.getBody().readString();
     
      Assert.assertEquals(200, response.getStatus());
      Assert.assertTrue(body.indexOf("TRACE /") != -1);
    }
View Full Code Here

   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
   
    for (int i = 0; i < 5; i++) {
      HttpRequest request = new HttpRequest("PUT", "/", "text/plain", "test123456789");
      IHttpResponse response = con.call(request);
     
      Assert.assertEquals(201, response.getStatus());
    }
 
   
View Full Code Here

   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
   
    for (int i = 0; i < 5; i++) {
      HttpRequest request = new HttpRequest("DELETE", "/someResource");
      IHttpResponse response = con.call(request);
     
      Assert.assertEquals(200, response.getStatus());
    }
 
   
View Full Code Here

   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
   
    for (int i = 0; i < 5; i++) {
      HttpRequest request = new HttpRequest("OPTIONS", "/");
      IHttpResponse response = con.call(request);
     
      Assert.assertEquals(200, response.getStatus());
      Assert.assertTrue(response.getHeader("allow").indexOf("GET") != -1);
     
    }
View Full Code Here

   
    HttpClientConnection con = new HttpClientConnection("localhost", proxy.getLocalPort());
   
    // setup a tunnel
    HttpRequest request = new HttpRequest("CONNECT", "localhost:" + securedServer.getLocalPort());
    IHttpResponse response = con.call(request);
     
    Assert.assertEquals(200, response.getStatus());
   

    // send the requests
View Full Code Here

    Assert.assertEquals(200, response.getStatus());
   

    // send the requests
    for (int i = 0; i < 10; i++) {
      response = con.call(new GetRequest("/"));
      Assert.assertEquals(200, response.getStatus());
      Assert.assertTrue(response.getBody().readString().indexOf("works") != -1);
    }
   
    con.close();
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

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.