Examples of PostRequest


Examples of org.xlightweb.PostRequest

   
    HttpClient httpClient = new HttpClient();
   
   
    FutureResponseHandler rh1 = new FutureResponseHandler();
    httpClient.send(new PostRequest("http://localhost:" + server.getLocalPort() + "/?waittimeSec=1", "text/plain", "test"), rh1);
    QAUtil.sleep(300);
    Assert.assertEquals(1, wp.getRunning());

   
    FutureResponseHandler rh2 = new FutureResponseHandler();
    httpClient.send(new PostRequest("http://localhost:" + server.getLocalPort() + "/?waittimeSec=1", "text/plain", "test"), rh2);
    QAUtil.sleep(300);
    Assert.assertEquals(2, wp.getRunning());
   
    QAUtil.sleep(1500);
    Assert.assertEquals(0, wp.getRunning());
View Full Code Here

Examples of org.xlightweb.PostRequest

   
    HttpClient httpClient = new HttpClient();
   
   
    FutureResponseHandler rh1 = new FutureResponseHandler();
    httpClient.send(new PostRequest("http://localhost:" + server.getLocalPort() + "/?waittimeSec=1", "text/plain", "test"), rh1);
    QAUtil.sleep(300);
    Assert.assertTrue("thread name " + reqHdl.getDataHandlerThreadName() + " does not starts with worker#", reqHdl.getDataHandlerThreadName().startsWith("worker#"));

    Assert.assertEquals(200, rh1.getResponse().getStatus());
   
View Full Code Here

Examples of org.xlightweb.PostRequest

   
    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.getBlockingBody().toString());
 
    con.close();
View Full Code Here

Examples of org.xlightweb.PostRequest

   
    IHttpRequestHandler filter = new IHttpRequestHandler() {

      public void onRequest(final IHttpExchange exchange) throws IOException {

        PostRequest newRequest = new PostRequest(exchange.getRequest().getRequestUrl().toString(), "text/plain", "Hello");
       
        IHttpResponseHandler respHdl = new IHttpResponseHandler() {
       
          public void onResponse(IHttpResponse response) throws IOException {
            exchange.send(response);
          }
         
          public void onException(IOException ioe) {
           
          }
         
        };
       
       
        exchange.forward(newRequest, respHdl);
      }
    };
   
   
    chain.addLast(filter);
    chain.addLast(new EchoHandler());
   
    IServer server = new HttpServer(0, chain);
    ConnectionUtils.start(server);
   
   
    PostRequest req = new PostRequest("http://localhost:" + server.getLocalPort() + "/", "text/plain", "test123456");
    req.setHeader("Host", "localhost");
    req.setHeader("User-Agent", "me");

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

    con.write(req.toString());
     
    String header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
    int contentLength = QAUtil.readContentLength(header);
     
    String body = con.readStringByLength(contentLength);
View Full Code Here

Examples of org.xlightweb.PostRequest

   
    IServer server = new HttpServer(0, chain);
    ConnectionUtils.start(server);
   
   
    PostRequest req = new PostRequest("http://localhost:" + server.getLocalPort() + "/", "text/plain", "test123456");
    req.setHeader("Host", "localhost");
    req.setHeader("User-Agent", "me");

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

    con.write(req.toString());
     
    String header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
    int contentLength = QAUtil.readContentLength(header);
     
    String body = con.readStringByLength(contentLength);
View Full Code Here

Examples of org.xlightweb.PostRequest

   
    IServer server = new HttpServer(0, chain);
    ConnectionUtils.start(server);
   
   
    PostRequest req = new PostRequest("http://localhost:" + server.getLocalPort() + "/", "text/plain", "test123456");
    req.setHeader("Host", "localhost");
    req.setHeader("User-Agent", "me");


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

    con.write(req.toString());
     
    String header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
    Assert.assertTrue(header.indexOf("Transfer-Encoding: chunked") != -1);
   
    int firstChunkLength =  Integer.parseInt(con.readStringByDelimiter("\r\n"), 16);
View Full Code Here

Examples of org.xlightweb.PostRequest

   
    IServer server = new HttpServer(0, chain);
    ConnectionUtils.start(server);
   
 
    PostRequest req = new PostRequest("http://localhost:" + server.getLocalPort() + "/", "text/plain", "test123456");
    req.setHeader("Host", "localhost");
    req.setHeader("User-Agent", "me");

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

    con.write(req.toString());
     
    String header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
    int contentLength = QAUtil.readContentLength(header);
     
    String body = con.readStringByLength(contentLength);
View Full Code Here

Examples of org.xlightweb.PostRequest

   
    IServer server = new HttpServer(chain);
    ConnectionUtils.start(server);
 
   
    PostRequest req = new PostRequest("http://localhost:" + server.getLocalPort() + "/", "text/plain", "test123456");
    req.setHeader("Host", "localhost");
    req.setHeader("User-Agent", "me");

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

    con.write(req.toString());
     
    String header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
    int contentLength = QAUtil.readContentLength(header);
     
    String body = con.readStringByLength(contentLength);
View Full Code Here

Examples of org.xlightweb.PostRequest

   
    IServer server = new HttpServer(chain);
    ConnectionUtils.start(server);
   
   
    PostRequest req = new PostRequest("http://localhost:" + server.getLocalPort() + "/", "text/plain", "test123456");
    req.setHeader("Host", "localhost");
    req.setHeader("User-Agent", "me");

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

    con.write(req.toString());
     
    con.readStringByDelimiter("\r\n\r\n");
   
    int firstChunkLength =  Integer.parseInt(con.readStringByDelimiter("\r\n"), 16);
    String body = con.readStringByLength(firstChunkLength);
View Full Code Here

Examples of org.xlightweb.PostRequest

    IServer server = new HttpServer(chain);
    ConnectionUtils.start(server);
 
   
   
    PostRequest req = new PostRequest("http://localhost:" + server.getLocalPort() + "/", "text/plain", "uftu234567");
    req.setHeader("Host", "localhost");
    req.setHeader("User-Agent", "me");


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

    con.write(req.toString());
     
    String header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
     
    int firstChunkLength =  Integer.parseInt(con.readStringByDelimiter("\r\n"), 16);
    String body = con.readStringByLength(firstChunkLength);
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.