org.riotfamily.cachius.servlet
Class ZippedResponseHandler

java.lang.Object
  extended by org.riotfamily.cachius.servlet.SessionIdCacheHandler
      extended by org.riotfamily.cachius.servlet.ResponseCapturingHandler
          extended by org.riotfamily.cachius.servlet.ZippedResponseHandler
All Implemented Interfaces:
CacheHandler
Direct Known Subclasses:
ControllerCacheHandler

public abstract class ZippedResponseHandler
extends ResponseCapturingHandler

Abstract CacheHandler that supports zipped content.

Author:
Felix Gnass [fgnass at neteye dot de]

Field Summary
 
Fields inherited from interface org.riotfamily.cachius.CacheHandler
CACHE_ETERNALLY
 
Constructor Summary
ZippedResponseHandler(HttpServletRequest request, HttpServletResponse response, CacheKeyAugmentor cacheKeyAugmentor)
           
 
Method Summary
protected  void augmentCacheKey(StringBuffer key)
           
protected  boolean clientAcceptsGzip()
          Returns whether the Accept-Encoding header contains "gzip".
protected  boolean isZip()
           
protected  void postProcess(CacheItem cacheItem)
           
protected  boolean responseCanBeZipped()
          Checks whether the response can be compressed.
protected abstract  boolean responseShouldBeZipped()
           
 void setMinSize(int minSize)
           
protected  boolean shouldZip()
           
protected  boolean userAgentHasGzipBugs()
          Returns whether the User-Agent has known gzip-related bugs.
 
Methods inherited from class org.riotfamily.cachius.servlet.ResponseCapturingHandler
handleInternal, handleUncached, updateCacheItemInternal, writeCacheItemInternal
 
Methods inherited from class org.riotfamily.cachius.servlet.SessionIdCacheHandler
getCacheKey, getCacheKeyInternal, getLastModified, getRequest, getSessionIdEncoder, getTimeToLive, updateCacheItem, writeCacheItem
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZippedResponseHandler

public ZippedResponseHandler(HttpServletRequest request,
                             HttpServletResponse response,
                             CacheKeyAugmentor cacheKeyAugmentor)
Method Detail

setMinSize

public void setMinSize(int minSize)

shouldZip

protected boolean shouldZip()

responseShouldBeZipped

protected abstract boolean responseShouldBeZipped()

isZip

protected boolean isZip()

augmentCacheKey

protected void augmentCacheKey(StringBuffer key)
Overrides:
augmentCacheKey in class SessionIdCacheHandler

postProcess

protected final void postProcess(CacheItem cacheItem)
                          throws IOException
Overrides:
postProcess in class SessionIdCacheHandler
Throws:
IOException

responseCanBeZipped

protected boolean responseCanBeZipped()
Checks whether the response can be compressed. This is the case when the client accepts gzip encoded content, the user-agent has no known gzip-related bugs and the request is not an include request.


clientAcceptsGzip

protected boolean clientAcceptsGzip()
Returns whether the Accept-Encoding header contains "gzip".


userAgentHasGzipBugs

protected boolean userAgentHasGzipBugs()
Returns whether the User-Agent has known gzip-related bugs. This is true for Internet Explorer < 6.0 SP2 and Mozilla 4.06, 4.07 and 4.08. The method will also return true if the User-Agent header is not present or empty.