Package org.xlightweb.client

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


        HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
       
        byte[] data = QAUtil.generateByteArray(400000);
        PostRequest request = new PostRequest("http://localhost:" + server.getLocalPort() + "/test", "text/plain", data);
       
        IHttpResponse response = con.call(request);
       
        Assert.assertNull(response.getAttribute("org.xlightweb.HttpClientConnection.100-continueReceived"));
        Assert.assertEquals(200, response.getStatus());
        Assert.assertArrayEquals(data, response.getBody().readBytes());
       
View Full Code Here


        HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
       
        byte[] data = QAUtil.generateByteArray(400000);
        PostRequest request = new PostRequest("http://localhost:" + server.getLocalPort() + "/test", "text/plain", data);
       
        IHttpResponse response = con.call(request);
       
        Assert.assertNull(response.getAttribute("org.xlightweb.HttpClientConnection.100-continueReceived"));
        Assert.assertEquals(200, response.getStatus());
        Assert.assertArrayEquals(data, response.getBody().readBytes());
       
View Full Code Here

     
      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());
        Assert.assertEquals("12345", response.getBody().readString());

     
      con.close();
View Full Code Here

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

        Assert.assertEquals(200, response.getStatus());
        Assert.assertEquals("12345", response.getBody().readString());
       
        System.out.println("second call");
        try {
            response = con.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/"));
            Assert.fail("ClosedChannelException expected");
        } catch (ClosedChannelException expected) { }     
       
       
        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() + "/"));
        try {
            response.getBody().readString();
            Assert.fail("ProtocolException expected");
        } catch (ProtocolException expected) { }
View Full Code Here

     
      IHttpRequestHandler reqHdl = new IHttpRequestHandler() {
       
          public void onRequest(IHttpExchange exchange) throws IOException, BadMessageException {
              HttpClientConnection con = new HttpClientConnection("localhost", oldServer.getLocalPort());
              IHttpResponse response = con.call(new GetRequest("http://localhost:" + oldServer.getLocalPort() + "/"));
             
              exchange.send(response);
          }
      };
     
View Full Code Here

        Server server = new Server(dh);
        server.start();
       
       
        HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
        IHttpResponse response = con.call(new GetRequest("/"));
       
        Assert.assertEquals(200, response.getStatus());
       
        String body = response.getBlockingBody().readString();
        Assert.assertEquals("123456789012345", body);
View Full Code Here

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

        Server server = new Server(dh);
        server.start();
       
       
        HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
        IHttpResponse response = con.call(new GetRequest("/"));
       
        Assert.assertEquals(200, response.getStatus());
       
        String body = response.getBlockingBody().readString();
        Assert.assertEquals("123456789012345", body);
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.