From: Kai Moritz Date: Sun, 11 Mar 2012 08:22:41 +0000 (+0100) Subject: AccelerationWrapper erweitert jetzt nicht mehr HttpServletResponseWrapper X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=672f062d477264d87bf84778771c2c5abc8b479a;p=percentcodec AccelerationWrapper erweitert jetzt nicht mehr HttpServletResponseWrapper --- diff --git a/cachecontrol/src/main/java/de/halbekunst/juplo/cachecontrol/AcceleratorFilter.java b/cachecontrol/src/main/java/de/halbekunst/juplo/cachecontrol/AcceleratorFilter.java index 5fee7367..501c3a27 100644 --- a/cachecontrol/src/main/java/de/halbekunst/juplo/cachecontrol/AcceleratorFilter.java +++ b/cachecontrol/src/main/java/de/halbekunst/juplo/cachecontrol/AcceleratorFilter.java @@ -19,9 +19,9 @@ import javax.servlet.ServletException; import javax.servlet.ServletOutputStream; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; +import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpServletResponseWrapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowire; @@ -85,7 +85,7 @@ public class AcceleratorFilter implements Filter { } - class AccelerationWrapper extends HttpServletResponseWrapper implements CacheMethodHandle { + class AccelerationWrapper implements HttpServletResponse, CacheMethodHandle { private final HttpServletRequest request; private final HttpServletResponse response; @@ -110,7 +110,6 @@ public class AcceleratorFilter implements Filter { AccelerationWrapper(HttpServletRequest request, HttpServletResponse response) throws IOException { - super(response); this.request = request; this.response = response; @@ -171,7 +170,7 @@ public class AcceleratorFilter implements Filter { public void addDateHeader(String name, long value) { if (!guessing) { - super.addDateHeader(name, value); + response.addDateHeader(name, value); return; } @@ -193,14 +192,14 @@ public class AcceleratorFilter implements Filter { } /** Unknown header: pass throug! */ - super.addDateHeader(name, value); + response.addDateHeader(name, value); } @Override public void addHeader(String name, String value) { if (!guessing) { - super.addHeader(name, value); + response.addHeader(name, value); return; } @@ -213,7 +212,7 @@ public class AcceleratorFilter implements Filter { public void addIntHeader(String name, int value) { if (!guessing) { - super.addIntHeader(name, value); + response.addIntHeader(name, value); return; } @@ -224,7 +223,7 @@ public class AcceleratorFilter implements Filter { public void setDateHeader(String name, long value) { if (!guessing) { - super.setDateHeader(name, value); + response.setDateHeader(name, value); return; } @@ -246,14 +245,14 @@ public class AcceleratorFilter implements Filter { } /** Unknown header: pass throug! */ - super.setDateHeader(name, value); + response.setDateHeader(name, value); } @Override public void setHeader(String name, String value) { if (!guessing) { - super.setHeader(name, value); + response.setHeader(name, value); return; } @@ -264,7 +263,7 @@ public class AcceleratorFilter implements Filter { public void setIntHeader(String name, int value) { if (!guessing) { - super.setIntHeader(name, value); + response.setIntHeader(name, value); return; } @@ -541,9 +540,9 @@ public class AcceleratorFilter implements Filter { /** Pass header through, if no value from intrest was found */ if (overwrite) - super.setHeader(name, value); + response.setHeader(name, value); else - super.addHeader(name, value); + response.addHeader(name, value); } private void calculateCacheSeconds() { @@ -553,6 +552,99 @@ public class AcceleratorFilter implements Filter { } } + @Override + public void addCookie(Cookie cookie) { + // TODO: Je nach Vary-Einstellung ETag anpassen? + response.addCookie(cookie); + } + + @Override + public boolean containsHeader(String name) { + return response.containsHeader(name); + } + + @Override + public String encodeURL(String url) { + return response.encodeURL(url); + } + + @Override + public String encodeRedirectURL(String url) { + return response.encodeRedirectURL(url); + } + + @Override + public String encodeUrl(String url) { + return response.encodeUrl(url); + } + + @Override + public String encodeRedirectUrl(String url) { + return response.encodeRedirectUrl(url); + } + + @Override + public void sendError(int sc, String msg) throws IOException { + // TODO: Decoration anpassen/anstoßen?!? + response.sendError(sc,msg); + } + + @Override + public void sendError(int sc) throws IOException { + // TODO: Decoration anpassen/anstoßen?!? + response.sendError(sc); + } + + @Override + public void sendRedirect(String location) throws IOException { + // TODO: Decoration anpassen/anstoßen?!? + response.sendRedirect(location); + } + + @Override + public String getCharacterEncoding() { + return response.getCharacterEncoding(); + } + + @Override + public String getContentType() { + return response.getContentType(); + } + + @Override + public void setCharacterEncoding(String charset) { + // TODO: Je nach Vary-Einstellung ETag anpassen? + response.setCharacterEncoding(charset); + } + + @Override + public void setContentType(String type) { + // TODO: Je nach Vary-Einstellung ETag anpassen? + response.setContentType(type); + } + + @Override + public int getBufferSize() { + return response.getBufferSize(); + } + + @Override + public boolean isCommitted() { + // TODO: Eigene commit-Kontrolle wegen Dekorations-Einstiegspunkt?!? + return response.isCommitted(); + } + + @Override + public void setLocale(Locale loc) { + // TODO: Je nach Vary-Einstellung ETag anpassen? + response.setLocale(loc); + } + + @Override + public Locale getLocale() { + return getLocale(); + } + class CountingServletOutputStream extends ServletOutputStream {