You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by re...@apache.org on 2008/08/19 19:56:14 UTC

svn commit: r687110 - /cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/SitemapServlet.java

Author: reinhard
Date: Tue Aug 19 10:56:13 2008
New Revision: 687110

URL: http://svn.apache.org/viewvc?rev=687110&view=rev
Log:
don't write null content into the response output stream. This leads to unexpected behaviour in the case of e.g. a 401 response

Modified:
    cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/SitemapServlet.java

Modified: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/SitemapServlet.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/SitemapServlet.java?rev=687110&r1=687109&r2=687110&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/SitemapServlet.java (original)
+++ cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/SitemapServlet.java Tue Aug 19 10:56:13 2008
@@ -141,14 +141,17 @@
                 response.setContentType(mimeType);
             }
 
-            response.setContentLength(contentLengh);
             response.setStatus(statusCode);
-            if (this.logger.isInfoEnabled()) {
-                this.logger.info("Going to send response: mimeType=" + mimeType + ", contentLength=" + contentLengh
-                        + ", statusCode=" + statusCode + ", lastModified=" + lastModified);
-            }
 
-            response.getOutputStream().write(baos.toByteArray());
+            if (contentLengh > 0) {
+                response.setContentLength(contentLengh);
+                if (this.logger.isInfoEnabled()) {
+                    this.logger.info("Going to send response: mimeType=" + mimeType + ", contentLength=" + contentLengh
+                            + ", statusCode=" + statusCode + ", lastModified=" + lastModified);
+                }
+
+                response.getOutputStream().write(baos.toByteArray());
+            }
         } catch (Exception e) {
             String msg = "An exception occurred while executing the sitemap.";
             this.logger.error(msg, e);