Author: ssmiweve Date: 2007-10-11 10:28:17 +0200 (Thu, 11 Oct 2007) New Revision: 5820
Modified: branches/2.15/skinresourcefeed/src/main/java/no/sesat/commons/resourcefeed/ResourceServlet.java Log: SEARCH-3580 - Private resources, from ResourceServlet, are not to be cached by mod_cache Modified: branches/2.15/skinresourcefeed/src/main/java/no/sesat/commons/resourcefeed/ResourceServlet.java =================================================================== --- branches/2.15/skinresourcefeed/src/main/java/no/sesat/commons/resourcefeed/ResourceServlet.java 2007-10-11 07:47:05 UTC (rev 5819) +++ branches/2.15/skinresourcefeed/src/main/java/no/sesat/commons/resourcefeed/ResourceServlet.java 2007-10-11 08:28:17 UTC (rev 5820) @@ -179,14 +179,16 @@ // ok, check configuration resources are private. LOG.trace(DEBUG_CLIENT_IP + ipAddr); - if (RESTRICTED.contains(extension) && !isIpAllowed(ipAddr)) { + final boolean restricted = RESTRICTED.contains(extension); + + if (restricted && !isIpAllowed(ipAddr)) { response.setContentType("text/html;charset=UTF-8"); response.getOutputStream().print(ERR_RESTRICTED_AREA); LOG.warn(ipAddr + ERR_TRIED_TO_ACCESS); } else { - serveResource(configName, request, response); + serveResource(configName, restricted, request, response); } } else { // not allowed to cross-reference resources. @@ -234,6 +236,7 @@ private void serveResource( final String configName, + final boolean restricted, final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { @@ -250,11 +253,13 @@ // Write response headers before response data according to javadoc for HttpServlet.html#doGet(..) - // Allow this URL to be cached indefinitely. + // Allow any public URL to be cached indefinitely. // Each jvm restart alters the number that appears in the URL being enough to ensure // nothing is cached across deployment versions. - response.setHeader("Cache-Control", "Public"); - response.setDateHeader("Expires", Long.MAX_VALUE); + if(!restricted){ + response.setHeader("Cache-Control", "Public"); + response.setDateHeader("Expires", Long.MAX_VALUE); + } // Avoid writing out the response body if it's a HEAD request or a GET that the browser has cache for boolean writeBody = !"HEAD".equals(request.getMethod()); _______________________________________________ Kernel-commits mailing list Kernel-commits@sesat.no http://sesat.no/mailman/listinfo/kernel-commits