Examples of RequestHandlerChain


Examples of org.xlightweb.RequestHandlerChain

 
 
  @Test
    public void testStreamedResponse() throws Exception {
     
        RequestHandlerChain chain = new RequestHandlerChain();

       
        IHttpRequestHandler rh = new IHttpRequestHandler() {
           
            public void onRequest(IHttpExchange exchange) throws IOException, BadMessageException {
                exchange.getRequest();
               
                BodyDataSink dataSink = exchange.send(new HttpResponseHeader(200));
                dataSink.write("test");
               
                QAUtil.sleep(200);
                dataSink.write("1234");
                dataSink.close();
            }
        };
        chain.addLast(rh);
       
        IHttpServer server = new HttpServer(chain);
        server.start();
       
       
View Full Code Here

Examples of org.xlightweb.RequestHandlerChain

    
    @Test
    public void testStreamedForward() throws Exception {
        System.setProperty("org.xlightweb.showDetailedError", "true");
       
        RequestHandlerChain chain = new RequestHandlerChain();

       
        IHttpRequestHandler rh = new IHttpRequestHandler() {
           
            public void onRequest(IHttpExchange exchange) throws IOException, BadMessageException {
                IHttpRequest request = exchange.getRequest();
               
                BodyDataSink dataSink = exchange.forward(request.getRequestHeader());
                dataSink.write("addedLine\r\n");
                dataSink.write(request.getBody().readString());
                dataSink.close();
            }
        };
        chain.addLast(rh);
       
       
        IHttpRequestHandler rh2 = new IHttpRequestHandler() {
           
            public void onRequest(IHttpExchange exchange) throws IOException, BadMessageException {
                IHttpRequest request = exchange.getRequest();
                exchange.send(new HttpResponse(200, request.getBody().readString()));
            }
        };
        chain.addLast(rh2);

       
        IHttpServer server = new HttpServer(chain);
        server.start();
       
View Full Code Here

Examples of org.xlightweb.RequestHandlerChain

      System.out.println("testChainFound");
   
      File file = QAUtil.createTestfile_400k();
      String basepath = file.getParentFile().getAbsolutePath();

    RequestHandlerChain chain = new RequestHandlerChain();
    chain.addLast(new FileServiceRequestHandler(basepath));
    IServer server = new HttpServer(chain);

    server.start();
   
   
View Full Code Here

Examples of org.xlightweb.RequestHandlerChain

      File file = QAUtil.createTestfile_400k();
      String basepath = file.getParentFile().getAbsolutePath();

   
    RequestHandlerChain chain = new RequestHandlerChain();
    chain.addLast(new FileServiceRequestHandler(basepath));
    IServer server = new HttpServer(chain);
    server.start();
   
   
    IBlockingConnection con = new BlockingConnection("localhost", server.getLocalPort());
View Full Code Here

Examples of org.xlightweb.RequestHandlerChain

      System.out.println("testChainHandledBySuccessor");

      File file = QAUtil.createTestfile_400k();
      String basepath = file.getParentFile().getAbsolutePath();

    RequestHandlerChain chain = new RequestHandlerChain();
    chain.addLast(new FileServiceRequestHandler(basepath));
    chain.addLast(new BusinessHandler());
   
    IServer server = new HttpServer(chain);
    server.start();
   
   
View Full Code Here

Examples of org.xlightweb.RequestHandlerChain

      System.out.println("testChainHandledByFileServiceNotSuccessor");
   
      File file = QAUtil.createTestfile_400k();
      String basepath = file.getParentFile().getAbsolutePath();

    RequestHandlerChain chain = new RequestHandlerChain();
    chain.addLast(new FileServiceRequestHandler(basepath));
    chain.addLast(new BusinessHandler());
   
    IServer server = new HttpServer(chain);
    server.start();
   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
View Full Code Here

Examples of org.xlightweb.RequestHandlerChain

      System.out.println("testChainLogInterceptor");
 
      File file = QAUtil.createTestfile_400k();
      String basepath = file.getParentFile().getAbsolutePath();

    RequestHandlerChain chain = new RequestHandlerChain();
    chain.addLast(new LogHandler());
    FileServiceRequestHandler fileSrv = new FileServiceRequestHandler(basepath);
    chain.addLast(fileSrv);
   
    IServer server = new HttpServer(chain);
    server.start();
   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
View Full Code Here

Examples of org.xlightweb.RequestHandlerChain

        System.out.println("testCachingValidationBased");

        File file = QAUtil.createTestfile_40k();
        String basepath = file.getParentFile().getAbsolutePath();
       
        RequestHandlerChain chain = new RequestHandlerChain();
        chain.addLast(new CacheHandler(500));
        chain.addLast(new FileServiceRequestHandler(basepath, true));
       
        IServer server = new HttpServer(chain);
        server.start();
       
        // first request
View Full Code Here

Examples of org.xlightweb.RequestHandlerChain

        System.out.println("testCachingExpiredBased");

        File file = QAUtil.createTestfile_40k();
        String basepath = file.getParentFile().getAbsolutePath();
       
        RequestHandlerChain chain = new RequestHandlerChain();
        chain.addLast(new CacheHandler(500));
        chain.addLast(new FileServiceRequestHandler(basepath, 60));
       
        IServer server = new HttpServer(chain);
        server.start();
       
        // first request
View Full Code Here

Examples of org.xlightweb.RequestHandlerChain

   
   
    @Test
    public void testNotFoundChain() throws Exception {

        RequestHandlerChain chain = new RequestHandlerChain();
       
        File file = QAUtil.createTestfile_400k();
        String basepath = file.getParentFile().getAbsolutePath();
       
        IHttpRequestHandler businessHandler = new IHttpRequestHandler() {
           
            public void onRequest(IHttpExchange exchange) throws IOException, BadMessageException {
                exchange.send(new HttpResponse(200, "text/plain", "OK"));
            }
        };
        chain.addLast(businessHandler);
       
        FileServiceRequestHandler fileHandler = new FileServiceRequestHandler(basepath, true);
        chain.addLast(fileHandler);
       
        IServer server = new HttpServer(chain);
        server.start();
       
        HttpClient httpClient = new HttpClient();
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.