/** * This static method is used when the resource being served by the servlet keeps track of the object hashcode, * and so no state needs to be maintained by this handler. */ public static boolean checkRequest(HttpServletRequest request, HttpServletResponse response, int hashCode) { return checkRequest(request, response, calculateEtag(hashCode)); }
public HashChangedHandler(int hashCode) { modified(hashCode); }
private static boolean checkRequest(HttpServletRequest request, HttpServletResponse response, String etagString) { if ("true".equals(System.getProperty("atlassian.disable.caches", "false"))) return false; // response.setDateHeader("Last-Modified",lastModified); response.setHeader("ETag", etagString); long ifModifiedSince = request.getDateHeader("If-Modified-Since"); String ifNoneMatch = request.getHeader("If-None-Match"); if (noConditionalGetHeadersFound(ifModifiedSince, ifNoneMatch) // || isContentModifiedSince(ifModifiedSince, lastModified) || !etagMatches(ifNoneMatch, etagString)) { return false; } response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); return true; }
/** * Check whether we need to generate a response for this request. Set the necessary headers on the response, and if * we don't need to provide content, set the response status to 304. * * If this method returns true, the caller should not perform any more processing on the request. * * @return true if we don't need to provide any data to satisfy this request */ public boolean checkRequest(HttpServletRequest request, HttpServletResponse response) { return checkRequest(request, response, etag); }
private void modified(int hashCode) { etag = calculateEtag(hashCode); }