response.sendError(HttpServletResponse.SC_NOT_FOUND, request
.getRequestURI());
return false;
}
ResourceDescriptor rd = handler.getResourceDescriptor(request, relPath);
if (rd == null) {
// no handler found or relPath incomplete
response.sendError(HttpServletResponse.SC_NOT_FOUND, request
.getRequestURI());
return false;
}
setHeaders(response, rd);
// check if modified since
long ifModifiedSince = request.getDateHeader("If-Modified-Since");
long lastMod = rd.getLastModified();
if (lastMod != -1L && ifModifiedSince >= lastMod) {
response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
return false;
}
// server the resource
if (copyContent) {
InputStream is = handler.getInputStream(request, rd);
if (is == null) {
// resource not found or access denied
response.sendError(HttpServletResponse.SC_NOT_FOUND, request
.getRequestURI());
return false;
}
copyContent(response, is);
if (logDebug) {
long stop = System.currentTimeMillis();
Tracing.logDebug("Serving resource '" + relPath + "' ("+rd.getSize()+" bytes) in "+ (stop-start) +"ms with handler '" + handlerName + "'.", StaticsLegacyDispatcher.class);
}
}
return true;
}