@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (request instanceof HttpServletRequest && response instanceof HttpServletResponse) { HttpServletRequest httpRequest = (HttpServletRequest) request; HttpServletResponse httpResponse = (HttpServletResponse) response; if (response.isCommitted()) { if (log.isDebugEnabled()) { log.debug(sm.getString( "expiresFilter.responseAlreadyCommited", httpRequest.getRequestURL())); } chain.doFilter(request, response); } else { XHttpServletResponse xResponse = new XHttpServletResponse( httpRequest, httpResponse); chain.doFilter(request, xResponse); if (!xResponse.isWriteResponseBodyStarted()) { // Empty response, manually trigger // onBeforeWriteResponseBody() onBeforeWriteResponseBody(httpRequest, xResponse); } } } else { chain.doFilter(request, response); } }
boolean expirationHeaderHasBeenSet = response.containsHeader(HEADER_EXPIRES) || contains(response.getCacheControlHeader(), "max-age"); if (expirationHeaderHasBeenSet) { if (log.isDebugEnabled()) { "expiresFilter.expirationHeaderAlreadyDefined", request.getRequestURI(), Integer.valueOf(response.getStatus()), response.getContentType())); if (response.getStatus() == skippedStatusCode) { if (log.isDebugEnabled()) { log.debug(sm.getString("expiresFilter.skippedStatusCode", request.getRequestURI(), Integer.valueOf(response.getStatus()), response.getContentType()));
break; case LAST_MODIFICATION_TIME: if (response.isLastModifiedHeaderSet()) { try { long lastModified = response.getLastModifiedHeader(); calendar = Calendar.getInstance(); calendar.setTimeInMillis(lastModified);
String contentType = response.getContentType();
String contentType = response.getContentType();
String contentType = response.getContentType();
String contentType = response.getContentType();
String contentType = response.getContentType();
String contentType = response.getContentType(); if (contentType != null) { contentType = contentType.toLowerCase(Locale.ENGLISH);
String contentType = response.getContentType(); if (contentType != null) { contentType = contentType.toLowerCase(Locale.ENGLISH);
String contentType = response.getContentType();
log.debug(sm.getString("expiresFilter.noExpirationConfigured", request.getRequestURI(), Integer.valueOf(response.getStatus()), response.getContentType())); log.debug(sm.getString("expiresFilter.setExpirationDate", request.getRequestURI(), Integer.valueOf(response.getStatus()), response.getContentType(), expirationDate)); ((expirationDate.getTime() - System.currentTimeMillis()) / 1000); String cacheControlHeader = response.getCacheControlHeader(); String newCacheControlHeader = (cacheControlHeader == null) ? maxAgeDirective : cacheControlHeader + ", " + maxAgeDirective; response.setHeader(HEADER_CACHE_CONTROL, newCacheControlHeader); response.setDateHeader(HEADER_EXPIRES, expirationDate.getTime());
log.debug(sm.getString("expiresFilter.noExpirationConfigured", request.getRequestURI(), Integer.valueOf(response.getStatus()), response.getContentType())); log.debug(sm.getString("expiresFilter.setExpirationDate", request.getRequestURI(), Integer.valueOf(response.getStatus()), response.getContentType(), expirationDate)); ((expirationDate.getTime() - System.currentTimeMillis()) / 1000); String cacheControlHeader = response.getCacheControlHeader(); String newCacheControlHeader = (cacheControlHeader == null) ? maxAgeDirective : cacheControlHeader + ", " + maxAgeDirective; response.setHeader(HEADER_CACHE_CONTROL, newCacheControlHeader); response.setDateHeader(HEADER_EXPIRES, expirationDate.getTime());
break; case LAST_MODIFICATION_TIME: if (response.isLastModifiedHeaderSet()) { try { long lastModified = response.getLastModifiedHeader(); calendar = Calendar.getInstance(); calendar.setTimeInMillis(lastModified);
String contentType = response.getContentType();
log.debug(sm.getString("expiresFilter.noExpirationConfigured", request.getRequestURI(), Integer.valueOf(response.getStatus()), response.getContentType())); log.debug(sm.getString("expiresFilter.setExpirationDate", request.getRequestURI(), Integer.valueOf(response.getStatus()), response.getContentType(), expirationDate)); ((expirationDate.getTime() - System.currentTimeMillis()) / 1000); String cacheControlHeader = response.getCacheControlHeader(); String newCacheControlHeader = (cacheControlHeader == null) ? maxAgeDirective : cacheControlHeader + ", " + maxAgeDirective; response.setHeader(HEADER_CACHE_CONTROL, newCacheControlHeader); response.setDateHeader(HEADER_EXPIRES, expirationDate.getTime());
break; case LAST_MODIFICATION_TIME: if (response.isLastModifiedHeaderSet()) { try { long lastModified = response.getLastModifiedHeader(); calendar = Calendar.getInstance(); calendar.setTimeInMillis(lastModified);
break; case LAST_MODIFICATION_TIME: if (response.isLastModifiedHeaderSet()) { try { long lastModified = response.getLastModifiedHeader(); calendar = Calendar.getInstance(); calendar.setTimeInMillis(lastModified);
log.debug(sm.getString("expiresFilter.noExpirationConfigured", request.getRequestURI(), Integer.valueOf(response.getStatus()), response.getContentType())); log.debug(sm.getString("expiresFilter.setExpirationDate", request.getRequestURI(), Integer.valueOf(response.getStatus()), response.getContentType(), expirationDate)); ((expirationDate.getTime() - System.currentTimeMillis()) / 1000); String cacheControlHeader = response.getCacheControlHeader(); String newCacheControlHeader = (cacheControlHeader == null) ? maxAgeDirective : cacheControlHeader + ", " + maxAgeDirective; response.setHeader(HEADER_CACHE_CONTROL, newCacheControlHeader); response.setDateHeader(HEADER_EXPIRES, expirationDate.getTime());
log.debug(sm.getString("expiresFilter.noExpirationConfigured", request.getRequestURI(), Integer.valueOf(response.getStatus()), response.getContentType())); log.debug(sm.getString("expiresFilter.setExpirationDate", request.getRequestURI(), Integer.valueOf(response.getStatus()), response.getContentType(), expirationDate)); ((expirationDate.getTime() - System.currentTimeMillis()) / 1000); String cacheControlHeader = response.getCacheControlHeader(); String newCacheControlHeader = (cacheControlHeader == null) ? maxAgeDirective : cacheControlHeader + ", " + maxAgeDirective; response.setHeader(HEADER_CACHE_CONTROL, newCacheControlHeader); response.setDateHeader(HEADER_EXPIRES, expirationDate.getTime());