[Laszlo-dev] [Laszlo-checkins] r2614 - openlaszlo/branches/legals/WEB-INF/lps/server/src/org/openlaszlo/servlets/responders
Max Carlson
max at openlaszlo.org
Tue Nov 21 14:51:18 PST 2006
Reminder: this only fixes lzt=object to return 304s if the file hasn't
been modified. This doesn't take care of lzt=lfc requests. You should
probably fix it for both...
-Max
hqm at openlaszlo.org wrote:
> Author: hqm
> Date: 2006-11-21 06:37:16 -0800 (Tue, 21 Nov 2006)
> New Revision: 2614
>
> Modified:
> openlaszlo/branches/legals/WEB-INF/lps/server/src/org/openlaszlo/servlets/responders/ResponderLFC.java
> Log:
> send proper last-modified info so DHTML LFC requests can be cached in browser
> reviewed by max
>
>
> Modified: openlaszlo/branches/legals/WEB-INF/lps/server/src/org/openlaszlo/servlets/responders/ResponderLFC.java
> ===================================================================
> --- openlaszlo/branches/legals/WEB-INF/lps/server/src/org/openlaszlo/servlets/responders/ResponderLFC.java 2006-11-21 13:45:19 UTC (rev 2613)
> +++ openlaszlo/branches/legals/WEB-INF/lps/server/src/org/openlaszlo/servlets/responders/ResponderLFC.java 2006-11-21 14:37:16 UTC (rev 2614)
> @@ -18,6 +18,7 @@
> import javax.servlet.ServletOutputStream;
> import javax.servlet.http.HttpServletRequest;
> import javax.servlet.http.HttpServletResponse;
> +import org.openlaszlo.utils.LZHttpUtils;
> import org.openlaszlo.compiler.CompilationEnvironment;
> import org.openlaszlo.utils.FileUtils;
> import org.openlaszlo.utils.StringUtils;
> @@ -34,18 +35,32 @@
> {
> private static Logger mLogger = Logger.getLogger(ResponderLFC.class);
>
> - /**
> - * Overridden method from ReponseCompile.
> - *
> - * @param req unused
> - */
> - protected long getLastModified(String fileName, HttpServletRequest req)
> + private boolean notModified(long lastModified, HttpServletRequest req,
> + HttpServletResponse res)
> + throws IOException
> {
> - // We don't care about other dependencies since all we show is the
> - // top-level LZX file.
> - return new File(fileName).lastModified();
> + if (lastModified != 0) {
> +
> + String lms = LZHttpUtils.getDateString(lastModified);
> +
> + // Check last-modified and if-modified-since dates
> + String ims = req.getHeader(LZHttpUtils.IF_MODIFIED_SINCE);
> + long ifModifiedSince = LZHttpUtils.getDate(ims);
> +
> + if (ifModifiedSince != -1) {
> + if (lastModified <= ifModifiedSince) {
> + res.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
> + return true;
> + }
> + }
> +
> + res.setHeader(LZHttpUtils.LAST_MODIFIED, lms);
> + }
> +
> + return false;
> }
>
> +
> /**
> */
> protected void respondImpl(HttpServletRequest req,
> @@ -54,7 +69,6 @@
> {
> ServletOutputStream out = res.getOutputStream();
>
> -
> String runtime = req.getParameter("lzr");
> if (runtime == null) {
> runtime = "swf7";
> @@ -89,6 +103,14 @@
>
> File lfcfile = new File(path, "/lfc/LFC"+runtime+profile+debug+"."+extension);
>
> + long lastModified = lfcfile.lastModified();
> + // Round to the nearest second.
> + lastModified = ((lastModified + 500L)/1000L) * 1000L;
> + if (notModified(lastModified, req, res)) {
> + return;
> + }
> +
> +
> try {
> res.setContentType ("application/x-javascript");
>
>
>
> _______________________________________________
> Laszlo-checkins mailing list
> Laszlo-checkins at openlaszlo.org
> http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins
More information about the Laszlo-dev
mailing list