Add a request URI to the FileCache
or use the cache to
send the static resources.
if ( socketChannel == null || !FileCacheFactory.isEnabled())
return Handler.CONTINUE;
// If not initialized, dont' continue
if ( fileCache == null && handlerCode != Handler.RESPONSE_PROCEEDED){
return Handler.CONTINUE;
}
if ( handlerCode == Handler.RESPONSE_PROCEEDED ){
CoyoteRequest cr =
(CoyoteRequest)request.getNote(CoyoteAdapter.ADAPTER_NOTES);
if ( cr != null && cr.getWrapper() != null){
String mappedServlet = cr.getWrapper().getName();
if ( !mappedServlet.equals(FileCache.DEFAULT_SERVLET_NAME) )
return Handler.CONTINUE;
if ( cr.getContext().findConstraints().length == 0
&& cr.getContext().findFilterDefs().length == 0 ){
if (!fileCache.isEnabled()) return Handler.CONTINUE;
String docroot;
if ( cr.getContextPath().equals("") ){
docroot = cr.getContext().getDocBase();
} else {
docroot = SelectorThread.getWebAppRootPath();
}
String requestURI = cr.getRequestURI();
Response response = cr.getCoyoteRequest().getResponse();
MimeHeaders headers = response.getMimeHeaders();
boolean xPoweredBy = (
(CoyoteConnector)cr.getConnector()).isXpoweredBy();
fileCache.add(mappedServlet,docroot,requestURI,headers,
xPoweredBy);
}
}
} else if ( handlerCode == Handler.REQUEST_BUFFERED ) {
if ( algorithm.startReq != -1 ){
if ( fileCache.sendCache(algorithm.ascbuf,
algorithm.startReq,
algorithm.lengthReq,
socketChannel, true ) ){
return Handler.BREAK;
}
}
}
return Handler.CONTINUE;