From d1a067158051e0529691eabba6d61764993b7938 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Thu, 14 Jul 2011 12:58:39 +0200 Subject: [PATCH] Die Log-Meldungen enthalten jetzt auch den Query-String --- .../cachecontrol/CacheControlInterceptor.java | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/cachecontrol/src/main/java/de/halbekunst/juplo/cachecontrol/CacheControlInterceptor.java b/cachecontrol/src/main/java/de/halbekunst/juplo/cachecontrol/CacheControlInterceptor.java index bfdf97ab..260048cb 100644 --- a/cachecontrol/src/main/java/de/halbekunst/juplo/cachecontrol/CacheControlInterceptor.java +++ b/cachecontrol/src/main/java/de/halbekunst/juplo/cachecontrol/CacheControlInterceptor.java @@ -52,9 +52,23 @@ public class CacheControlInterceptor implements HandlerInterceptor { if (!cacheable.isGenerateCacheHeaders(request)) return true; + String url = null; + if (log.isDebugEnabled()) { + if (request.getQueryString() == null) { + url = request.getRequestURI(); + } + else { + StringBuilder builder = new StringBuilder(); + builder.append(request.getRequestURI()); + builder.append('?'); + builder.append(request.getQueryString()); + url = builder.toString(); + } + } + int cacheSeconds = cacheable.getCacheSeconds(request); if (cacheSeconds < 0) { - log.debug("{}: caching disabled!", request.getRequestURI()); + log.debug("{}: caching disabled!", url); response.setDateHeader(HEADER_DATE, now); response.setDateHeader(HEADER_EXPIRES, 0); response.addHeader(HEADER_PRAGMA, "no-cache"); @@ -107,24 +121,24 @@ public class CacheControlInterceptor implements HandlerInterceptor { * negative Werte für Last-Modified zurückliefert. */ if (log.isDebugEnabled()) - log.debug("Not modified since {}: {}", new Date(ifModifiedSince), request.getRequestURI()); + log.debug("Not modified since {}: {}", new Date(ifModifiedSince), url); if (ifNoneMatch == null) { /** Neue Anfrage oder HTTP/1.0 Client! */ - log.debug("ETag nicht gesetzt: 304 {}", request.getRequestURI()); + log.debug("ETag nicht gesetzt: 304 {}", url); response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); return false; } } if (ifNoneMatch != null && ifNoneMatch.equals(eTag)) { - log.debug("{}: ETag {} not changed -> 304 ", request.getRequestURI(), ifNoneMatch); + log.debug("{}: ETag {} not changed -> 304 ", url, ifNoneMatch); response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); return false; } - log.debug("{}: first up!", request.getRequestURI()); + log.debug("{}: first up!", url); /** HTTP/1.1-Caching-Header richtig setzen!! */ response.setDateHeader(HEADER_LAST_MODIFIED, lastModified); -- 2.20.1