add some HTTP headers in the view servlets
This commit is contained in:
@ -15,11 +15,27 @@ boolean rendered = false;
|
|||||||
String c = request.getParameter("c");
|
String c = request.getParameter("c");
|
||||||
if (c != null && c.length() > 0) {
|
if (c != null && c.length() > 0) {
|
||||||
java.io.OutputStream cout = response.getOutputStream();
|
java.io.OutputStream cout = response.getOutputStream();
|
||||||
response.setContentType("image/png");
|
|
||||||
response.setHeader("Cache-Control", "max-age=86400"); // cache for a day
|
|
||||||
String base = net.i2p.I2PAppContext.getGlobalContext().getBaseDir().getAbsolutePath();
|
String base = net.i2p.I2PAppContext.getGlobalContext().getBaseDir().getAbsolutePath();
|
||||||
String file = "docs" + java.io.File.separatorChar + "icons" + java.io.File.separatorChar +
|
String file = "docs" + java.io.File.separatorChar + "icons" + java.io.File.separatorChar +
|
||||||
"flags" + java.io.File.separatorChar + c + ".png";
|
"flags" + java.io.File.separatorChar + c + ".png";
|
||||||
|
java.io.File ffile = new java.io.File(base, file);
|
||||||
|
long lastmod = ffile.lastModified();
|
||||||
|
if (lastmod > 0) {
|
||||||
|
long iflast = request.getDateHeader("If-Modified-Since");
|
||||||
|
// iflast is -1 if not present; round down file time
|
||||||
|
if (iflast >= ((lastmod / 1000) * 1000)) {
|
||||||
|
response.sendError(304, "Not Modified");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
response.setDateHeader("Last-Modified", lastmod);
|
||||||
|
// cache for a day
|
||||||
|
response.setDateHeader("Expires", net.i2p.I2PAppContext.getGlobalContext().clock().now() + 86400000l);
|
||||||
|
response.setHeader("Cache-Control", "public, max-age=86400");
|
||||||
|
}
|
||||||
|
long length = ffile.length();
|
||||||
|
if (length > 0)
|
||||||
|
response.setHeader("Content-Length", Long.toString(length));
|
||||||
|
response.setContentType("image/png");
|
||||||
try {
|
try {
|
||||||
net.i2p.util.FileUtil.readFile(file, base, cout);
|
net.i2p.util.FileUtil.readFile(file, base, cout);
|
||||||
rendered = true;
|
rendered = true;
|
||||||
|
@ -19,7 +19,6 @@ if (uri.endsWith(".css")) {
|
|||||||
} else if (uri.endsWith(".ico")) {
|
} else if (uri.endsWith(".ico")) {
|
||||||
response.setContentType("image/x-icon");
|
response.setContentType("image/x-icon");
|
||||||
}
|
}
|
||||||
response.setHeader("Cache-Control", "max-age=86400"); // cache for a day
|
|
||||||
/*
|
/*
|
||||||
* User or plugin themes
|
* User or plugin themes
|
||||||
* If the request is for /themes/console/foo/bar/baz,
|
* If the request is for /themes/console/foo/bar/baz,
|
||||||
@ -44,6 +43,23 @@ if (themePath != null)
|
|||||||
else
|
else
|
||||||
base = net.i2p.I2PAppContext.getGlobalContext().getBaseDir().getAbsolutePath() +
|
base = net.i2p.I2PAppContext.getGlobalContext().getBaseDir().getAbsolutePath() +
|
||||||
java.io.File.separatorChar + "docs";
|
java.io.File.separatorChar + "docs";
|
||||||
|
java.io.File file = new java.io.File(base, uri);
|
||||||
|
long lastmod = file.lastModified();
|
||||||
|
if (lastmod > 0) {
|
||||||
|
long iflast = request.getDateHeader("If-Modified-Since");
|
||||||
|
// iflast is -1 if not present; round down file time
|
||||||
|
if (iflast >= ((lastmod / 1000) * 1000)) {
|
||||||
|
response.sendError(304, "Not Modified");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
response.setDateHeader("Last-Modified", lastmod);
|
||||||
|
// cache for a day
|
||||||
|
response.setDateHeader("Expires", net.i2p.I2PAppContext.getGlobalContext().clock().now() + 86400000l);
|
||||||
|
response.setHeader("Cache-Control", "public, max-age=86400");
|
||||||
|
}
|
||||||
|
long length = file.length();
|
||||||
|
if (length > 0)
|
||||||
|
response.setHeader("Content-Length", Long.toString(length));
|
||||||
try {
|
try {
|
||||||
net.i2p.util.FileUtil.readFile(uri, base, response.getOutputStream());
|
net.i2p.util.FileUtil.readFile(uri, base, response.getOutputStream());
|
||||||
} catch (java.io.IOException ioe) {
|
} catch (java.io.IOException ioe) {
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
2011-01-15 zzz
|
||||||
|
* Console: Add some HTTP headers in the view servlets
|
||||||
|
|
||||||
|
2011-01-12 zzz
|
||||||
|
* Log: Fix rare initialization problem
|
||||||
|
* PrivateKey: Fix hashCode()
|
||||||
|
|
||||||
2011-01-09 zzz
|
2011-01-09 zzz
|
||||||
* DataHelper: Speed up and annotate sortStructures()
|
* DataHelper: Speed up and annotate sortStructures()
|
||||||
* Data Structures: More caching improvements, don't cache where we shouldn't
|
* Data Structures: More caching improvements, don't cache where we shouldn't
|
||||||
|
@ -18,7 +18,7 @@ public class RouterVersion {
|
|||||||
/** deprecated */
|
/** deprecated */
|
||||||
public final static String ID = "Monotone";
|
public final static String ID = "Monotone";
|
||||||
public final static String VERSION = CoreVersion.VERSION;
|
public final static String VERSION = CoreVersion.VERSION;
|
||||||
public final static long BUILD = 10;
|
public final static long BUILD = 11;
|
||||||
|
|
||||||
/** for example "-test" */
|
/** for example "-test" */
|
||||||
public final static String EXTRA = "";
|
public final static String EXTRA = "";
|
||||||
|
Reference in New Issue
Block a user