Examples of PostRequest


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

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


    IHttpResponse response = httpClient.call(req);

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

Examples of org.xlightweb.PostRequest

        server.start();
       
        HttpClient httpClient = new HttpClient();
        httpClient.setCacheMaxSizeKB(100);
       
        IHttpRequest request = new PostRequest("http://localhost:" + server.getLocalPort() + "/", "text/plain", "test");
        IHttpResponse resp = httpClient.call(request);
        Assert.assertEquals(200, resp.getStatus());
        Assert.assertEquals("test", resp.getBlockingBody().readString());
       
        QAUtil.sleep(1000);
       
        request = new PostRequest("http://localhost:" + server.getLocalPort() + "/", "text/plain", "test");
        resp = httpClient.call(request);
        Assert.assertEquals(200, resp.getStatus());
        Assert.assertEquals("test", resp.getBlockingBody().readString());
       
        QAUtil.sleep(1000);
View Full Code Here

Examples of org.xlightweb.PostRequest

        server.start();
       
        HttpClient httpClient = new HttpClient();
        httpClient.setCacheMaxSizeKB(100);
       
        IHttpResponse resp = httpClient.call(new PostRequest("http://localhost:" + server.getLocalPort() + "/", "text/plain", "test"));
        Assert.assertEquals(200, resp.getStatus());
        Assert.assertEquals("test", resp.getBlockingBody().readString());
        Assert.assertTrue(resp.getHeader(CacheHandler.XHEADER_NAME).equals("miss"));
       
        QAUtil.sleep(1000);
       
        resp = httpClient.call(new PostRequest("http://localhost:" + server.getLocalPort() + "/", "text/plain", "test"));
        Assert.assertEquals(200, resp.getStatus());
        Assert.assertTrue(resp.getHeader(CacheHandler.XHEADER_NAME).equals("miss (revalidated)"));
        Assert.assertEquals("test", resp.getBlockingBody().readString());
       
        QAUtil.sleep(1000);
View Full Code Here

Examples of org.xlightweb.PostRequest

        server.start();
       
        HttpClient httpClient = new HttpClient();
        httpClient.setCacheMaxSizeKB(100);
       
        IHttpResponse resp = httpClient.call(new PostRequest("http://localhost:" + server.getLocalPort() + "/", "text/plain", "test"));
        Assert.assertEquals(200, resp.getStatus());
        Assert.assertEquals("test", resp.getBlockingBody().readString());
        Assert.assertTrue(resp.getHeader(CacheHandler.XHEADER_NAME).equals("miss"));
       
        QAUtil.sleep(1000);
       
       
        IHttpRequest request = new PostRequest("http://localhost:" + server.getLocalPort() + "/", "text/plain", "test");
        resp = httpClient.call(request);
       
       
        Assert.assertEquals(200, resp.getStatus());
        Assert.assertTrue(resp.getHeader(CacheHandler.XHEADER_NAME).equals("miss (revalidated)"));
View Full Code Here

Examples of org.xlightweb.PostRequest

        server.start();
       
        HttpClient httpClient = new HttpClient();
        httpClient.setCacheMaxSizeKB(10);
       
        IHttpRequest request = new PostRequest("http://localhost:" + server.getLocalPort() + "/", "text/plain", "request text");
        IHttpResponse resp = httpClient.call(request);
        Assert.assertEquals(200, resp.getStatus());
        Assert.assertEquals("test", resp.getBlockingBody().readString());
        Assert.assertNull(resp.getHeader(CacheHandler.XHEADER_NAME));
       
        QAUtil.sleep(2000);
       
        request = new PostRequest("http://localhost:" + server.getLocalPort() + "/", "text/plain", "request text");
        resp = httpClient.call(request);
        Assert.assertEquals(200, resp.getStatus());
       
        if (!resp.getHeader(CacheHandler.XHEADER_NAME).startsWith("HIT")) {
            System.out.println(request);
View Full Code Here

Examples of org.xlightweb.PostRequest

        server.start();
       
        HttpClient httpClient = new HttpClient();
        httpClient.setCacheMaxSizeKB(10);
       
        IHttpRequest request = new PostRequest("http://localhost:" + server.getLocalPort() + "/", "text/plain", QAUtil.generateByteArray(5000));
        IHttpResponse resp = httpClient.call(request);
        Assert.assertEquals(200, resp.getStatus());
        Assert.assertEquals("test", resp.getBlockingBody().readString());
        Assert.assertNull(resp.getHeader(CacheHandler.XHEADER_NAME));
       
        QAUtil.sleep(2000);
       
        request = new PostRequest("http://localhost:" + server.getLocalPort() + "/", "text/plain", QAUtil.generateByteArray(5000));
        resp = httpClient.call(request);
        Assert.assertEquals(200, resp.getStatus());
        Assert.assertNull(resp.getHeader(CacheHandler.XHEADER_NAME));
        Assert.assertEquals("test", resp.getBlockingBody().readString());
       
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.