Examples of GetRequest


Examples of org.xlightweb.GetRequest

    server.start();
   
   
    HttpClient httpClient = new HttpClient();
   
    IHttpResponse response = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/site/" + testFile.getName()));
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals("application/octet-stream", response.getContentType());
    Assert.assertTrue(response.hasBody());
   
    response = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/rpc/getCustomers"));
    Assert.assertEquals(200, response.getStatus());
    Assert.assertTrue(response.getContentType().startsWith("text/plain"));
    Assert.assertTrue(response.hasBody());
   
    httpClient.close();
View Full Code Here

Examples of org.xlightweb.GetRequest

      IServer server = new HttpServer(port, rootCtx);
      server.start();

      HttpClient httpClient = new HttpClient()
     
      IHttpResponse response = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort()+ "/Person/1"));
      Assert.assertEquals(200, response.getStatus());
      Assert.assertEquals("person", response.getBlockingBody().readString());
     
      response = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort()+ "/Account/1"));
        Assert.assertEquals(200, response.getStatus());
        Assert.assertEquals("account", response.getBlockingBody().readString());
     
      httpClient.close();
      server.close();
View Full Code Here

Examples of org.xlightweb.GetRequest

    server.start();
   
   
    HttpClient httpClient = new HttpClient();
   
    IHttpResponse response = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/test"));
    Assert.assertEquals(200, response.getStatus());
   
    response = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/badRequest"));
    Assert.assertEquals(400, response.getStatus());

    httpClient.close();
    server.close();
  }
View Full Code Here

Examples of org.xlightweb.GetRequest

    server.start();
   
   
    HttpClient httpClient = new HttpClient();
   
    IHttpResponse response = httpClient.call(new GetRequest("http://localhost:" + jettyServer.getConnectors()[0].getLocalPort() + "/ctx1/test/you"));
    if (response.getStatus() != 200) {
      System.out.println("got " + response.getStatus() + " instead of 200");
      Assert.fail();
    }
   
    String body = response.getBlockingBody().readString();
    if (body.indexOf("contextPath=/ctx1") == -1) {
      System.out.println("contextPath=/ctx1 expected");
      Assert.fail();
    }
   
    if (body.indexOf("contextPath=/ctx1") == -1) {
      System.out.println("servletPath=/test expected");
      Assert.fail();
    }

   
    response = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/ctx1/test/you"));
    if (response.getStatus() != 200) {
      System.out.println("got " + response.getStatus());
      Assert.fail();
    }
   
View Full Code Here

Examples of org.xlightweb.GetRequest

    ctx.addHandler("/ctx1/*", hdl);
    Server server = new HttpServer(ctx);
    ConnectionUtils.start(server);
   
   
    GetRequest req = new GetRequest("http://localhost:" + server.getLocalPort() + "/ctx1/test/test2");
    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.GetRequest

    ctx.addHandler("/ctx1/*", hdl);
    Server server = new HttpServer(ctx);
    server.start();
   
   
    GetRequest req = new GetRequest("http://localhost:" + server.getLocalPort() + "/ctx1/test/test2");
    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.GetRequest

    Server server = new HttpServer(ctx);
    ConnectionUtils.start(server);
   
   
   
    GetRequest reqXSocket = new GetRequest("http://localhost:" + server.getLocalPort() + "/ctx1/test/test2");
    reqXSocket.setHeader("Host", "localhost");
    reqXSocket.setHeader("User-Agent", "me");

    GetRequest reqJetty = new GetRequest("http://localhost:" + servletEngine.getLocalPort() + "/ctx1/test/test2");
    reqJetty.setHeader("Host", "localhost");
    reqJetty.setHeader("User-Agent", "me");

   
    IBlockingConnection conXSocket = new BlockingConnection("localhost", server.getLocalPort());
    IBlockingConnection conJetty = new BlockingConnection("localhost", servletEngine.getLocalPort());

    conXSocket.write(reqXSocket.toString());
   
    String header = conXSocket.readStringByDelimiter("\r\n\r\n");
    int contentLength = QAUtil.readContentLength(header);
     
    String bodyXSocket = conXSocket.readStringByLength(contentLength);
   
   
    conJetty.write(reqJetty.toString());
   
    String headerJetty = conJetty.readStringByDelimiter("\r\n\r\n");
    int contentLengthJetty = QAUtil.readContentLength(headerJetty);
     
    String bodyJetty = conJetty.readStringByLength(contentLengthJetty);
View Full Code Here

Examples of org.xlightweb.GetRequest

    ConnectionUtils.start(server);
   
   
   
   
    GetRequest reqXSocket = new GetRequest("http://localhost:" + server.getLocalPort() + "/ctx0/ctx1/test/test2");
    reqXSocket.setHeader("Host", "localhost");
    reqXSocket.setHeader("User-Agent", "me");

   
    GetRequest reqJetty = new GetRequest("http://localhost:" + servletEngine.getLocalPort() + "/ctx0/ctx1/test/test2");
    reqJetty.setHeader("Host", "localhost");
    reqJetty.setHeader("User-Agent", "me");

   
    IBlockingConnection conXSocket = new BlockingConnection("localhost", server.getLocalPort());
    IBlockingConnection conJetty = new BlockingConnection("localhost", servletEngine.getLocalPort());

    conXSocket.write(reqXSocket.toString());
   
    String header = conXSocket.readStringByDelimiter("\r\n\r\n");
    int contentLength = QAUtil.readContentLength(header);
     
    String bodyXSocket = conXSocket.readStringByLength(contentLength);
   
   
    conJetty.write(reqJetty.toString());
   
    String headerJetty = conJetty.readStringByDelimiter("\r\n\r\n");
    int contentLengthJetty = QAUtil.readContentLength(headerJetty);
     
    String bodyJetty = conJetty.readStringByLength(contentLengthJetty);
View Full Code Here

Examples of org.xlightweb.GetRequest

    Server server = new HttpServer(ctxRoot);
    ConnectionUtils.start(server);
   
   

    GetRequest reqXSocket = new GetRequest("http://localhost:" + server.getLocalPort() + "/ctx0/ctx1/test/test2");
    reqXSocket.setHeader("Host", "localhost");
    reqXSocket.setHeader("User-Agent", "me");

   
    GetRequest reqJetty = new GetRequest("http://localhost:" + jettyServer.getConnectors()[0].getLocalPort() + "/ctx0/ctx1/test/test2");
    reqJetty.setHeader("Host", "localhost");
    reqJetty.setHeader("User-Agent", "me");

   
    IBlockingConnection conXSocket = new BlockingConnection("localhost", server.getLocalPort());
    IBlockingConnection conJetty = new BlockingConnection("localhost", jettyServer.getConnectors()[0].getLocalPort());

    conXSocket.write(reqXSocket.toString());
   
    String header = conXSocket.readStringByDelimiter("\r\n\r\n");
    int contentLength = QAUtil.readContentLength(header);
     
    String bodyXSocket = conXSocket.readStringByLength(contentLength);
   
   
    conJetty.write(reqJetty.toString());
   
    String headerJetty = conJetty.readStringByDelimiter("\r\n\r\n");
    int contentLengthJetty = QAUtil.readContentLength(headerJetty);
     
    String bodyJetty = conJetty.readStringByLength(contentLengthJetty);
View Full Code Here

Examples of org.xlightweb.GetRequest

    HttpServer server = new HttpServer(ctx);
    server.addConnectionHandler(hdl);
    server.start();
   
   
    GetRequest req = new GetRequest("http://localhost:" + server.getLocalPort() + "/ctx1/test/test2");
    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
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.