@Execution(Execution.NONTHREADED) class HeaderLogInterceptor implements IHttpRequestHandler { public void onRequest(final IHttpExchange exchange) throws IOException { IHttpResponseHandler respHdl = new IHttpResponseHandler() { public void onResponse(IHttpResponse response) throws IOException { System.out.println(response.getResponseHeader()); exchange.send(response); } public void onException(IOException ioe) { System.out.println(ioe.toString()); exchange.sendError(500); } }; System.out.println(exchange.getRequest().getRequestHeader()); exchange.forward(exchange.getRequest(), respHdl); } } RequestHandlerChain chain = new RequestHandlerChain(); chain.addLast(new HeaderLogInterceptor()); chain.addLast(new MySeviceHandler()); IServer server = new HttpServer(8080, chain); server.start();@author grro@xlightweb.org
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|