You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2004/09/23 11:04:51 UTC

svn commit: rev 47091 - in cocoon/trunk/src/java/org/apache/cocoon: caching components/pipeline/impl

Author: cziegeler
Date: Thu Sep 23 02:04:50 2004
New Revision: 47091

Modified:
   cocoon/trunk/src/java/org/apache/cocoon/caching/CachedResponse.java
   cocoon/trunk/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java
Log:
First version of caching mime-type of readers

Modified: cocoon/trunk/src/java/org/apache/cocoon/caching/CachedResponse.java
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/caching/CachedResponse.java	(original)
+++ cocoon/trunk/src/java/org/apache/cocoon/caching/CachedResponse.java	Thu Sep 23 02:04:50 2004
@@ -28,7 +28,7 @@
  *
  * @since 2.1
  * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
- * @version CVS $Id: CachedResponse.java,v 1.6 2004/03/05 13:02:45 bdelacretaz Exp $
+ * @version CVS $Id$
  */
 public class CachedResponse
         implements Serializable {
@@ -37,7 +37,8 @@
     protected final byte[]           response;
     protected Long                   expires;
     protected final long             lastModified;
-
+    protected String                 contentType;
+    
     /**
      * Create a new entry for the cache.
      *
@@ -128,4 +129,16 @@
         return lastModified;
     }
 
+    /**
+     * @return Returns the cached content type (or null).
+     */
+    public String getContentType() {
+        return this.contentType;
+    }
+    /**
+     * @param value The content type to cache.
+     */
+    public void setContentType(String value) {
+        this.contentType = value;
+    }
 }

Modified: cocoon/trunk/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java	(original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java	Thu Sep 23 02:04:50 2004
@@ -697,6 +697,9 @@
                             byte[] response = cachedObject.getResponse();
                             if (response.length > 0) {
                                 usedCache = true;
+                                if ( cachedObject.getContentType() != null ) {
+                                    environment.setContentType(cachedObject.getContentType());
+                                }
                                 outputStream = environment.getOutputStream(0);
                                 environment.setContentLength(response.length);
                                 outputStream.write(response);
@@ -748,10 +751,12 @@
 
                 // store the response
                 if (pcKey != null) {
+                    final CachedResponse res = new CachedResponse( new SourceValidity[] {readerValidity},
+                            ((CachingOutputStream)outputStream).getContent());
+                    res.setContentType(environment.getContentType());
                     this.cache.store(
                         pcKey,
-                        new CachedResponse( new SourceValidity[] {readerValidity},
-                                            ((CachingOutputStream)outputStream).getContent())
+                        res
                     );
                 }
             }