Package org.xlightweb

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


   
    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

    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

        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

        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

Related Classes of org.xlightweb.PostRequest

Copyright © 2018 www.massapicom. 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.