
import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;


public class TestServerMain extends AbstractHandler {
	public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
			throws IOException, ServletException {		
		response.setContentType("text/html;charset=utf-8");
		response.setStatus(HttpServletResponse.SC_OK);
		baseRequest.setHandled(true);
		response.getWriter().println("<h1>Hello Test" + request.getRequestURI() + "</h1>");
	}

	public static void main(String[] args) {
		if (args.length < 1) {
			showHelp();
			return;
		}
		
		System.out.println("Starting server");

		Server server = new Server(Integer.parseInt(args[0]));
		server.setHandler(new TestServerMain());

		try {
			server.start();
			System.out.println("Started TestServer");
			server.join();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	

	private static void showHelp() {
		System.out.println("Usage: [server-port]");
	}
}
@@ -23,16 +23,51 @@
 ption;%0A%0A
+import javax.servlet.AsyncContext;%0A
 import j
@@ -191,16 +191,187 @@
 ponse;%0A%0A
+import org.eclipse.jetty.continuation.Continuation;%0Aimport org.eclipse.jetty.continuation.ContinuationListener;%0Aimport org.eclipse.jetty.continuation.ContinuationSupport;%0A
 import o
@@ -556,16 +556,61 @@
 ndler %7B%0A
+%09%0A%09private static int ResponseDelay = 0;%0A%09%0A%09%0A
 %09public 
@@ -756,18 +756,761 @@
 eption %7B
+%0A
 %09%09
+if (ResponseDelay %3E 0) %7B%0A%09%09%09Continuation continuation = ContinuationSupport.getContinuation(request);%0A%0A%09%09%09if (continuation.isInitial()) %7B%0A%09%09%09%09continuation.setTimeout(ResponseDelay);%0A%09%09%09%09continuation.suspend();%0A%09%09%09%7D else %7B%0A%09%09%09%09sendResponse(baseRequest, request, response);%0A%09%09%09%7D%0A%0A%09%09%09continuation.addContinuationListener(new ContinuationListener() %7B%0A%09%09%09%09public void onTimeout(Continuation continuation) %7B%0A%09%09%09%09%09continuation.resume();%0A%09%09%09%09%7D%0A%0A%09%09%09%09public void onComplete(Continuation continuation) %7B%0A%09%09%09%09%7D%0A%09%09%09%7D);%0A%09%09%7D else %7B%0A%09%09%09System.out.println(%22x %22 + request);%0A%09%09%09sendResponse(baseRequest, request, response);%0A%09%09%7D%0A%09%7D%0A%0A%09private void sendResponse(Request baseRequest, HttpServletRequest request, HttpServletResponse response)%0A%09%09%09throws IOException %7B
 %0A%09%09respo
@@ -1824,16 +1824,91 @@
 rn;%0A%09%09%7D%0A
+%09%09if(args.length %3E= 2) %7B%0A%09%09%09ResponseDelay = Integer.parseInt(args%5B1%5D);%0A%09%09%7D%0A
 %09%09%0A%09%09Sys
@@ -1939,17 +1939,42 @@
 g server
-%22
+. Delay: %22 + ResponseDelay
 );%0A%0A%09%09Se

Test server with async response delay - for testing n-lane bridge