Anonymous avatar Anonymous committed bd71f28

CACHE-315 support for Content-Disposition Response Header

Comments (0)

Files changed (3)

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

     public static final String HEADER_CACHE_CONTROL = "Cache-Control";
     public static final String HEADER_ACCEPT_ENCODING = "Accept-Encoding";
     public static final String HEADER_ETAG = "ETag";
+    public static final String HEADER_CONTENT_DISPOSITION = "Content-Disposition";
 
     // Fragment parameter
     public static final int FRAGMENT_AUTODETECT = -1;

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

         if (CacheFilter.HEADER_ETAG.equalsIgnoreCase(name)) {
             result.setETag(value);
         }
+        
+        if (CacheFilter.HEADER_CONTENT_DISPOSITION.equalsIgnoreCase(name)) {
+            result.setContentDisposition(value);
+        }
 
         super.setHeader(name, value);
     }
             result.setETag(value);
         }
 
+        if (CacheFilter.HEADER_CONTENT_DISPOSITION.equalsIgnoreCase(name)) {
+            result.setContentDisposition(value);
+        }
+
         super.addHeader(name, value);
     }
 

src/java/com/opensymphony/oscache/web/filter/ResponseContent.java

     private long lastModified = -1;
     private long maxAge = -60;
     private String etag = null;
+    private String contentDisposition = null;
 
     public String getContentType() {
         return contentType;
         this.etag = etag;
     }
 
+    public String getContentDisposition() {
+        return contentDisposition;
+    }
+
+    public void setContentDisposition(String contentDisposition) {
+        this.contentDisposition = contentDisposition;
+    }
+
    /**
      * Set the Locale. We capture this so that when we serve this data from
      * cache, we can set the correct locale on the response.
                     httpResponse.addHeader(CacheFilter.HEADER_ETAG, etag);
                 }
                 
+                // add the content disposition header
+                if(contentDisposition != null) {
+                    httpResponse.addHeader(CacheFilter.HEADER_CONTENT_DISPOSITION, contentDisposition);
+                }
+                
                 // add the expires header
                 if (expires != Long.MAX_VALUE) {
                     httpResponse.setDateHeader(CacheFilter.HEADER_EXPIRES, expires);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.