Changeset 04d04d0


Ignore:
Timestamp:
Jan 15, 2011 10:23:57 PM (9 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
32b817f
Parents:
d4a717e
Message:

add some HTTP headers in the view servlets

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • apps/routerconsole/jsp/flags.jsp

    rd4a717e r04d04d0  
    1616if (c != null && c.length() > 0) {
    1717    java.io.OutputStream cout = response.getOutputStream();
    18     response.setContentType("image/png");
    19     response.setHeader("Cache-Control", "max-age=86400");  // cache for a day
    2018    String base = net.i2p.I2PAppContext.getGlobalContext().getBaseDir().getAbsolutePath();
    2119    String file = "docs" + java.io.File.separatorChar + "icons" + java.io.File.separatorChar +
    2220                  "flags" + java.io.File.separatorChar + c + ".png";
     21    java.io.File ffile = new java.io.File(base, file);
     22    long lastmod = ffile.lastModified();
     23    if (lastmod > 0) {
     24        long iflast = request.getDateHeader("If-Modified-Since");
     25        // iflast is -1 if not present; round down file time
     26        if (iflast >= ((lastmod / 1000) * 1000)) {
     27            response.sendError(304, "Not Modified");
     28            return;
     29        }
     30        response.setDateHeader("Last-Modified", lastmod);
     31        // cache for a day
     32        response.setDateHeader("Expires", net.i2p.I2PAppContext.getGlobalContext().clock().now() + 86400000l);
     33        response.setHeader("Cache-Control", "public, max-age=86400");
     34    }
     35    long length = ffile.length();
     36    if (length > 0)
     37        response.setHeader("Content-Length", Long.toString(length));
     38    response.setContentType("image/png");
    2339    try {
    2440        net.i2p.util.FileUtil.readFile(file, base, cout);
  • apps/routerconsole/jsp/viewtheme.jsp

    rd4a717e r04d04d0  
    2020  response.setContentType("image/x-icon");
    2121}
    22 response.setHeader("Cache-Control", "max-age=86400");  // cache for a day
    2322/*
    2423 * User or plugin themes
     
    4544    base = net.i2p.I2PAppContext.getGlobalContext().getBaseDir().getAbsolutePath() +
    4645              java.io.File.separatorChar + "docs";
     46java.io.File file = new java.io.File(base, uri);
     47long lastmod = file.lastModified();
     48if (lastmod > 0) {
     49    long iflast = request.getDateHeader("If-Modified-Since");
     50    // iflast is -1 if not present; round down file time
     51    if (iflast >= ((lastmod / 1000) * 1000)) {
     52        response.sendError(304, "Not Modified");
     53        return;
     54    }
     55    response.setDateHeader("Last-Modified", lastmod);
     56    // cache for a day
     57    response.setDateHeader("Expires", net.i2p.I2PAppContext.getGlobalContext().clock().now() + 86400000l);
     58    response.setHeader("Cache-Control", "public, max-age=86400");
     59}
     60long length = file.length();
     61if (length > 0)
     62    response.setHeader("Content-Length", Long.toString(length));
    4763try {
    4864    net.i2p.util.FileUtil.readFile(uri, base, response.getOutputStream());
  • history.txt

    rd4a717e r04d04d0  
     12011-01-15 zzz
     2    * Console: Add some HTTP headers in the view servlets
     3
     42011-01-12 zzz
     5    * Log: Fix rare initialization problem
     6    * PrivateKey: Fix hashCode()
     7
    182011-01-09 zzz
    29    * DataHelper: Speed up and annotate sortStructures()
  • router/java/src/net/i2p/router/RouterVersion.java

    rd4a717e r04d04d0  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 10;
     21    public final static long BUILD = 11;
    2222
    2323    /** for example "-test" */
Note: See TracChangeset for help on using the changeset viewer.