Examples of RequestHandlerChain


Examples of org.xlightweb.RequestHandlerChain

  @Test
  public void testReplaceResponseChunked() throws Exception {
      System.out.println("testReplaceResponseChunked");
 
    RequestHandlerChain chain = new RequestHandlerChain();
   
    IHttpRequestHandler filter = new IHttpRequestHandler() {

      public void onRequest(final IHttpExchange exchange) throws IOException {

        IHttpResponseHandler respHdl = new IHttpResponseHandler() {
       
          public void onResponse(IHttpResponse response) throws IOException {
           
            BodyDataSink bodyDataSink = exchange.send(new HttpResponseHeader(200, "text/plain"));
            bodyDataSink.write("Hello");
            QAUtil.sleep(200);
            bodyDataSink.write(" You");
            bodyDataSink.close();         
          }
         
          public void onException(IOException ioe) {
           
          }
         
        };
       
       
        exchange.forward(exchange.getRequest(), respHdl);
      }
    };
   
   
    chain.addLast(filter);
    chain.addLast(new EchoHandler());
   
    IServer server = new HttpServer(0, chain);
    ConnectionUtils.start(server);
   
   
View Full Code Here

Examples of org.xlightweb.RequestHandlerChain

 
  @Test
  public void testReplaceResponseBound() throws Exception {
      System.out.println("testReplaceResponseBound");
 
    RequestHandlerChain chain = new RequestHandlerChain();
   
    IHttpRequestHandler filter = new IHttpRequestHandler() {

      public void onRequest(final IHttpExchange exchange) throws IOException {

        IHttpResponseHandler respHdl = new IHttpResponseHandler() {
       
          public void onResponse(IHttpResponse response) throws IOException {
           
            BodyDataSink bodyDataSink = exchange.send(new HttpResponseHeader(200, "text/plain"), 9);
            bodyDataSink.write("Hello");
            QAUtil.sleep(200);
            bodyDataSink.write(" You");
            bodyDataSink.close();         
          }
         
          public void onException(IOException ioe) {
           
          }
         
        };
       
       
        exchange.forward(exchange.getRequest(), respHdl);
      }
    };
   
   
    chain.addLast(filter);
    chain.addLast(new EchoHandler());
   
    IServer server = new HttpServer(0, chain);
    ConnectionUtils.start(server);
   
 
View Full Code Here

Examples of org.xlightweb.RequestHandlerChain

 
  @Test
  public void testTimestamp() throws Exception {
      System.out.println("testTimestamp");
 
    RequestHandlerChain chain = new RequestHandlerChain();
   
    chain.addLast(new TimestampHandler());
    chain.addLast(new EchoHandler());
   
    IServer server = new HttpServer(chain);
    ConnectionUtils.start(server);
 
   
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.