Commits

Anonymous committed 2a639d2

Issue number: CACHE-38, CACHE-159
Submitted by: Andres March

Merge from HEAD

  • Participants
  • Parent commits dede3f9
  • Branches v2_1_1

Comments (0)

Files changed (2)

File src/core/java/com/opensymphony/oscache/web/filter/CacheFilter.java

  * @version $Revision$
  */
 public class CacheFilter implements Filter {
+
     private final Log log = LogFactory.getLog(this.getClass());
 
     // Header
+    public static final String HEADER_LAST_MODIFIED = "Last-Modified";
+    public static final String HEADER_CONTENT_TYPE = "Content-Type";
     public static final String HEADER_CONTENT_ENCODING = "Content-Encoding";
+    public static final String HEADER_EXPIRES = "Expires";
+    public static final String HEADER_IF_MODIFIED_SINCE = "If-Modified-Since";
+    public static final String HEADER_CACHE_CONTROL = "Cache-control";
+    public static final String HEADER_ACCEPT_ENCODING = "Accept-Encoding";
     
     // filter variables
     private FilterConfig config;

File src/core/java/com/opensymphony/oscache/web/filter/CacheHttpServletResponseWrapper.java

         if (log.isDebugEnabled()) {
             log.debug("header: " + name + ": " + value);
         }
-        
+
+        if (CacheFilter.HEADER_CONTENT_TYPE.equalsIgnoreCase(name)) {
+            result.setContentType(value);
+        }
+
         if (CacheFilter.HEADER_CONTENT_ENCODING.equalsIgnoreCase(name)) {
             result.setContentEncoding(value);
         }
             log.debug("header: " + name + ": " + value);
         }
 
+        if (CacheFilter.HEADER_CONTENT_TYPE.equalsIgnoreCase(name)) {
+            result.setContentType(value);
+        }
+
         if (CacheFilter.HEADER_CONTENT_ENCODING.equalsIgnoreCase(name)) {
             result.setContentEncoding(value);
         }
         super.addHeader(name, value);
     }
 
-    
     /**
      * Set the int value of the header
      *
      */
     public PrintWriter getWriter() throws IOException {
         if (cachedWriter == null) {
-            cachedWriter = new PrintWriter(new OutputStreamWriter(getOutputStream(), result.getContentEncoding()));
+            String encoding = getCharacterEncoding();
+            if (encoding != null) {
+                cachedWriter = new PrintWriter(new OutputStreamWriter(getOutputStream(), encoding));
+            } else { // using the default character encoding
+                cachedWriter = new PrintWriter(new OutputStreamWriter(getOutputStream()));
+            }
         }
 
         return cachedWriter;