Package org.xlightweb.client

Examples of org.xlightweb.client.HttpClientConnection.call()


   

    IHttpRequest request = new GetRequest("/" + file.getName());
    request.setHeader("Range", "bytes=-1");
   
    IHttpResponse response = con.call(request);
   
    Assert.assertEquals(206, response.getStatus());
    Assert.assertEquals(">", response.getBody().readString());
   
    file.delete();
View Full Code Here


   

    IHttpRequest request = new GetRequest("/" + file.getName());
    request.setHeader("Range", "bytes=170-");
   
    IHttpResponse response = con.call(request);
   
    Assert.assertEquals(400, response.getStatus());
   
    file.delete();
    con.close();
View Full Code Here

   

    IHttpRequest request = new GetRequest("/" + file.getName());
    request.setHeader("Range", "bytes=0-0,-1");
   
    IHttpResponse response = con.call(request);
       
    Assert.assertEquals(206, response.getStatus());
   
    file.delete();
    con.close();
View Full Code Here

   

    IHttpRequest request = new GetRequest("/" + file.getName());
    request.setHeader("Range", "bytes=0-0,37-67,-1");
   
    IHttpResponse response = con.call(request);
   
    QAUtil.sleep(1000);
    System.out.println(response);
   
    Assert.assertEquals(206, response.getStatus());
View Full Code Here

    IServer server = new HttpServer(new FileServiceRequestHandler(basepath));
    server.start();
   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());

    IHttpResponse response = con.call(new GetRequest("/" + file.getName()));
    Assert.assertEquals(200, response.getStatus());
   
    response.getBody().readString();
   
    String lastModified = response.getHeader("Last-Modified");
View Full Code Here

   
    String lastModified = response.getHeader("Last-Modified");
    GetRequest secondRequest = new GetRequest("/" + file.getName());
    secondRequest.setHeader("If-Modified-Since", lastModified);
   
    response = con.call(secondRequest);
    Assert.assertEquals("unexpected response " + response, 304, response.getStatus());
   
   
    file.delete();
    con.close();
View Full Code Here

    IServer server = new HttpServer(chain);
    server.start();
   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());

    IHttpResponse response = con.call(new GetRequest("/" + file.getName()));
    Assert.assertEquals(200, response.getStatus());

    File tempFile = QAUtil.createTempfile();
   
    RandomAccessFile raf = new RandomAccessFile(tempFile, "rw");
View Full Code Here

        IServer server = new HttpServer(chain);
        server.start();
       
        // first request
        HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
        IHttpResponse response = con.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/" + file.getName()));
        Assert.assertEquals(200, response.getStatus());
        Assert.assertTrue(QAUtil.isEquals(file, response.getBody().readByteBuffer()));
        con.close();

       
View Full Code Here

       
        QAUtil.sleep(1000);
       
        // repeated request (served by cache!)
        con = new HttpClientConnection("localhost", server.getLocalPort());
        response = con.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/" + file.getName()));
        Assert.assertEquals(200, response.getStatus());
        Assert.assertTrue(response.getHeader("X-Cache").startsWith("HIT - revalidated"));
        Assert.assertTrue(QAUtil.isEquals(file, response.getBody().readByteBuffer()));
        con.close();
View Full Code Here

        IServer server = new HttpServer(chain);
        server.start();
       
        // first request
        HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
        IHttpResponse response = con.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/" + file.getName()));
        Assert.assertEquals(200, response.getStatus());
        Assert.assertNotNull(response.getHeader("Expires"));
        Assert.assertTrue(QAUtil.isEquals(file, response.getBody().readByteBuffer()));
        con.close();
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.