Package org.xlightweb

Examples of org.xlightweb.PostRequest


          ConnectionUtils.registerMBean(server);
         
          HttpClient httpClient = new HttpClient();

          IHttpResponse response = httpClient.call(new PostRequest("http://localhost:" + server.getLocalPort() + "/s/", new NameValuePair("param", "value"), new NameValuePair("param2", "value2")));
          Assert.assertEquals(200, response.getStatus());

          QAUtil.sleep(1000);

         
View Full Code Here


        Assert.assertEquals("test", resp.getBlockingBody().readString());
       
       
        QAUtil.sleep(1000);
       
        resp = httpClient.call(new PostRequest("http://localhost:" + server.getLocalPort() + "/"));
        Assert.assertEquals(200, resp.getStatus());
        Assert.assertNull(resp.getHeader(CacheHandler.XHEADER_NAME));
        Assert.assertEquals("test", resp.getBlockingBody().readString());

       
View Full Code Here

        Assert.assertEquals("test", resp.getBody().readString());
       
       
        QAUtil.sleep(1000);
       
        resp = httpClient.call(new PostRequest("http://localhost:" + server.getLocalPort() + "/"));
        Assert.assertEquals(200, resp.getStatus());
        Assert.assertNull(resp.getHeader(CacheHandler.XHEADER_NAME));
        Assert.assertEquals("test", resp.getBody().readString());

       
View Full Code Here

          ConnectionUtils.registerMBean(server);
         
          HttpClient httpClient = new HttpClient();

          IHttpResponse response = httpClient.call(new PostRequest("http://localhost:" + server.getLocalPort() + "/s/", new String[] { "param=value", "param2=value2" }));
          Assert.assertEquals(200, response.getStatus());

          QAUtil.sleep(1000);

         
View Full Code Here

   
    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

   
    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

   
    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

   
    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

   
    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

   
    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

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.