}
}
public void serveStatic(HttpServletResponse servletResponse, HttpServletRequest servletRequest, RenderStatic renderStatic) throws IOException {
VirtualFile file = Play.getVirtualFile(renderStatic.file);
if (file == null || file.isDirectory() || !file.exists()) {
serve404(servletRequest, servletResponse, new NotFound("The file " + renderStatic.file + " does not exist"));
} else {
servletResponse.setContentType(MimeTypes.getContentType(file.getName()));
boolean raw = Play.pluginCollection.serveStatic(file, Request.current(), Response.current());
if (raw) {
copyResponse(Request.current(), Response.current(), servletRequest, servletResponse);
} else {
if (Play.mode == Play.Mode.DEV) {
servletResponse.setHeader("Cache-Control", "no-cache");
servletResponse.setHeader("Content-Length", String.valueOf(file.length()));
if (!servletRequest.getMethod().equals("HEAD")) {
copyStream(servletResponse, file.inputstream());
} else {
copyStream(servletResponse, new ByteArrayInputStream(new byte[0]));
}
} else {
long last = file.lastModified();
String etag = "\"" + last + "-" + file.hashCode() + "\"";
if (!isModified(etag, last, servletRequest)) {
servletResponse.setHeader("Etag", etag);
servletResponse.setStatus(304);
} else {
servletResponse.setHeader("Last-Modified", Utils.getHttpDateFormatter().format(new Date(last)));
servletResponse.setHeader("Cache-Control", "max-age=" + Play.configuration.getProperty("http.cacheControl", "3600"));
servletResponse.setHeader("Etag", etag);
copyStream(servletResponse, file.inputstream());
}
}
}
}
}