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 12:57:32 UTC

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

Author: cziegeler
Date: Thu Sep 23 03:57:30 2004
New Revision: 47095

Modified:
   cocoon/trunk/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java
   cocoon/trunk/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java
Log:
Only set contentType if the content is not from the cache

Modified: cocoon/trunk/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java	(original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java	Thu Sep 23 03:57:30 2004
@@ -475,10 +475,9 @@
             }
 
             return this.processReader(environment);
-        } else {
-            this.connectPipeline(environment);
-            return this.processXMLPipeline(environment);
         }
+        this.connectPipeline(environment);
+        return this.processXMLPipeline(environment);
     }
 
     /**
@@ -553,22 +552,7 @@
     throws ProcessingException {
         try {
             this.reader.setup(this.processor.getSourceResolver(),environment.getObjectModel(),readerSource,readerParam);
-            // Set the mime-type
-            // the behaviour has changed from 2.1.x to 2.2 according to bug #10277:
-            // MIME type declared in the sitemap (instance or declaration, in this order)
-            // Ask the Reader for a MIME type:
-            //     A *.doc reader could peek into the file
-            //     and return either text/plain or application/vnd.msword or
-            //     the reader can use MIME type declared in WEB-INF/web.xml or
-            //     by the server.
-            if ( this.readerMimeType != null ) {
-                environment.setContentType(this.readerMimeType);
-            } else {
-                final String mimeType = this.reader.getMimeType();
-                if (mimeType != null) {
-                    environment.setContentType(mimeType);
-                }
-            }
+
             // set the expires parameter on the pipeline if the reader is configured with one
             if (readerParam.isParameter("expires")) {
 	            // should this checking be done somewhere else??
@@ -583,6 +567,25 @@
         }
     }
 
+    protected void setMimeTypeForReader(Environment environment) {
+        // Set the mime-type
+        // the behaviour has changed from 2.1.x to 2.2 according to bug #10277:
+        // MIME type declared in the sitemap (instance or declaration, in this order)
+        // Ask the Reader for a MIME type:
+        //     A *.doc reader could peek into the file
+        //     and return either text/plain or application/vnd.msword or
+        //     the reader can use MIME type declared in WEB-INF/web.xml or
+        //     by the server.
+        if ( this.readerMimeType != null ) {
+            environment.setContentType(this.readerMimeType);
+        } else {
+            final String mimeType = this.reader.getMimeType();
+            if (mimeType != null) {
+                environment.setContentType(mimeType);
+            }
+        }        
+    }
+    
     protected boolean checkIfModified(Environment environment,
                                         long lastModified)
     throws ProcessingException {
@@ -602,6 +605,7 @@
     protected boolean processReader(Environment environment)
     throws ProcessingException {
         try {
+            this.setMimeTypeForReader(environment);
             if (this.reader.shouldSetContentLength()) {
                 ByteArrayOutputStream os = new ByteArrayOutputStream();
                 this.reader.setOutputStream(os);
@@ -673,10 +677,9 @@
         this.lastConsumer = consumer;
         if ( this.reader != null ) {
             throw new ProcessingException("Streaming of an internal pipeline is not possible with a reader.");
-        } else {
-            this.connectPipeline(environment);
-            return this.processXMLPipeline(environment);
         }
+        this.connectPipeline(environment);
+        return this.processXMLPipeline(environment);
     }
 
     /**

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 03:57:30 2004
@@ -699,6 +699,8 @@
                                 usedCache = true;
                                 if ( cachedObject.getContentType() != null ) {
                                     environment.setContentType(cachedObject.getContentType());
+                                } else {
+                                    this.setMimeTypeForReader(environment);
                                 }
                                 outputStream = environment.getOutputStream(0);
                                 environment.setContentLength(response.length);
@@ -732,6 +734,7 @@
                     }
                 }
 
+                this.setMimeTypeForReader(environment);
                 if (this.reader.shouldSetContentLength()) {
                     ByteArrayOutputStream os = new ByteArrayOutputStream();
                     this.reader.setOutputStream(os);