Package org.xlightweb

Examples of org.xlightweb.GetRequest


        };
       
        client.addInterceptor(reqHdl);
       
       
        GetRequest request = new GetRequest("http://localhost:" + server.getLocalPort() + "/");
        request.setHeader("Upgrade", "WebSocket");
        request.setHeader("Connection", "upgrade");
        request.setHeader("Origin", "http://websockets.org:" + server.getLocalPort());

        IHttpResponse response = client.call(request);
       
        IHttpConnection con = (IHttpConnection) response.getAttribute("org.xlightweb.client.connection");
        Assert.assertTrue(con.isOpen());
View Full Code Here


    server.start();
   
    HttpClient httpClient = new HttpClient();
   
    for (int i = 0; i < 10; i++) {
        IHttpResponse response = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/test?countRedirects=3"));
        Assert.assertEquals(200, response.getStatus());
       
        QAUtil.sleep(250);
    }
   
View Full Code Here

    ConnectionUtils.start(server);
   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
    con.setIdleTimeoutMillis(500);
   
    GetRequest request = new GetRequest("/");
    request.setHeader("sleep-time", Integer.toString(1000));
    try {
      con.call(request);
      Assert.fail("SocketTimeoutException expected");
    } catch (IOException expected) { }
   
View Full Code Here

    server.start();
 
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
    con.setBodyDataReceiveTimeoutMillis(1000);

    IHttpResponse response = con.call(new GetRequest("/?loops=3&waittime=200"));
    response.getBlockingBody().readString();
   
    response = con.call(new GetRequest("/?loops=1&waittime=2000"));
   
    try {
      response.getBlockingBody().readString();
      Assert.fail("ReceiveTimeoutException expected");
    } catch (ReceiveTimeoutException expected) { }
View Full Code Here

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

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

    QAUtil.sleep(1000);

   
View Full Code Here

        server.start();

        HttpClient httpClient = new HttpClient(SSLTestContextFactory.getSSLContext());
       
        IHttpResponse response = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/"));
        Assert.assertEquals(200, response.getStatus());
        Assert.assertEquals("OK", response.getBlockingBody().readString());

        QAUtil.sleep(500);
       
        response = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/"));
        Assert.assertEquals(200, response.getStatus());
        Assert.assertEquals("OK", response.getBlockingBody().readString());

        QAUtil.sleep(500);
        Assert.assertEquals(1, server.getNumHandledConnections())// connection has been reused
View Full Code Here

        server.start();

        HttpClient httpClient = new HttpClient(SSLTestContextFactory.getSSLContext());
       
        IHttpResponse response = httpClient.call(new GetRequest("https://localhost:" + server.getLocalPort() + "/"));
        Assert.assertEquals(200, response.getStatus());
        Assert.assertEquals("OK", response.getBlockingBody().readString());

        QAUtil.sleep(500);
       
        response = httpClient.call(new GetRequest("https://localhost:" + server.getLocalPort() + "/"));
        Assert.assertEquals(200, response.getStatus());
        Assert.assertEquals("OK", response.getBlockingBody().readString());

       
        QAUtil.sleep(500);
View Full Code Here


  @Test
  public void testFullURL() throws Exception {
   
    GetRequest req = new GetRequest("https://username:password@example.com:8042/over/there/index.dtb;type=animal?name=ferret#nose");
   
    Assert.assertEquals(true, req.isSecure());
    Assert.assertEquals("example.com", req.getServerName());
    Assert.assertEquals(8042, req.getServerPort());
    Assert.assertEquals("/over/there/index.dtb;type=animal", req.getRequestURI());
    Assert.assertEquals("name=ferret", req.getQueryString());
   
    Assert.assertEquals("https://example.com:8042/over/there/index.dtb;type=animal?name=ferret", req.getRequestUrl().toString());
  }
View Full Code Here

 
 
  @Test
  public void testMinimalURL() throws Exception {
   
    GetRequest req = new GetRequest("/");
   
    Assert.assertEquals(false, req.isSecure());
    Assert.assertNull(req.getServerName());
    Assert.assertEquals(-1, req.getServerPort());
    Assert.assertEquals("/", req.getRequestURI());
    Assert.assertNull(req.getQueryString());
   
    Assert.assertEquals("http:/", req.getRequestUrl().toString());
  }
View Full Code Here

    HttpServer server = new HttpServer(0, chain);
    server.setCloseOnSendingError(false);
    ConnectionUtils.start(server);
 
   
    GetRequest req = new GetRequest("http://localhost:" + server.getLocalPort() + "/");
    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("401") != -1);
    Assert.assertTrue(header.indexOf("WWW-Authenticate") != -1);
   
   
    req = new GetRequest("http://localhost:" + server.getLocalPort() + "/");
    req.setHeader("Authorization", "Basic YXNkYXNkOmFzZGFzZA==");

    con.write(req.toString());
   
    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.GetRequest

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.