@Test
public void testReplaceResponse() throws Exception {
System.out.println("testReplaceResponse");
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 {
HttpResponse newResponse = new HttpResponse(200, "text/plain", "Hello You");
exchange.send(newResponse);
}
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);