tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1044266 - in /tomcat/trunk: java/org/apache/catalina/servlets/DefaultServlet.java webapps/docs/changelog.xml
Date Fri, 10 Dec 2010 10:11:38 GMT
Author: markt
Date: Fri Dec 10 10:11:38 2010
New Revision: 1044266

URL: http://svn.apache.org/viewvc?rev=1044266&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=50413
Ensure 304s are not returned when using static files as error pages

Modified:
    tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java?rev=1044266&r1=1044265&r2=1044266&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java (original)
+++ tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java Fri Dec 10 10:11:38
2010
@@ -792,6 +792,9 @@ public class DefaultServlet
             }
         }
 
+        boolean isError =
+            response.getStatus() >= HttpServletResponse.SC_BAD_REQUEST;
+
         // Check if the conditions specified in the optional If headers are
         // satisfied.
         if (cacheEntry.context == null) {
@@ -799,8 +802,8 @@ public class DefaultServlet
             // Checking If headers
             boolean included =
                 (request.getAttribute(Globals.INCLUDE_CONTEXT_PATH_ATTR) != null);
-            if (!included
-                && !checkIfHeaders(request, response, cacheEntry.attributes)) {
+            if (!included && !isError &&
+                    !checkIfHeaders(request, response, cacheEntry.attributes)) {
                 return;
             }
 
@@ -828,21 +831,23 @@ public class DefaultServlet
             contentType = "text/html;charset=UTF-8";
 
         } else {
-            if (useAcceptRanges) {
-                // Accept ranges header
-                response.setHeader("Accept-Ranges", "bytes");
+            if (!isError) {
+                if (useAcceptRanges) {
+                    // Accept ranges header
+                    response.setHeader("Accept-Ranges", "bytes");
+                }
+    
+                // Parse range specifier
+                ranges = parseRange(request, response, cacheEntry.attributes);
+    
+                // ETag header
+                response.setHeader("ETag", cacheEntry.attributes.getETag());
+    
+                // Last-Modified header
+                response.setHeader("Last-Modified",
+                        cacheEntry.attributes.getLastModifiedHttp());
             }
 
-            // Parse range specifier
-            ranges = parseRange(request, response, cacheEntry.attributes);
-
-            // ETag header
-            response.setHeader("ETag", cacheEntry.attributes.getETag());
-
-            // Last-Modified header
-            response.setHeader("Last-Modified",
-                    cacheEntry.attributes.getLastModifiedHttp());
-
             // Get content length
             contentLength = cacheEntry.attributes.getContentLength();
             // Special case for zero length files, which would cause a

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1044266&r1=1044265&r2=1044266&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Fri Dec 10 10:11:38 2010
@@ -122,6 +122,10 @@
         <code>Store</code> associated with a <code>PersistentManager</code>.
         (markt) 
       </fix>
+      <fix>
+        <bug>50413</bug>: Ensure 304 responses are not returned when using
+        static files as error pages. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message