Author: markt
Date: Sat Jan 8 19:27:46 2011
New Revision: 1056775
URL: http://svn.apache.org/viewvc?rev=1056775&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/tc6.0.x/trunk/STATUS.txt
tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/DefaultServlet.java
tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml
Modified: tomcat/tc6.0.x/trunk/STATUS.txt
URL:
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/STATUS.txt?rev=1056775&r1=1056774&r2=1056775&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/STATUS.txt (original)
+++ tomcat/tc6.0.x/trunk/STATUS.txt Sat Jan 8 19:27:46 2011
@@ -102,12 +102,6 @@ PATCHES PROPOSED TO BACKPORT:
-0: markt - Patch doesn't apply cleanly to tc6.0.x/trunk
-1:
-* Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=50413
- Ensure 304s are not returned when using static files as error pages
- http://people.apache.org/~markt/patches/2011-01-04-bug50413-tc6.patch
- +1: markt, jfclere, kfujino
- -1:
-
* Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=48822
Include context name in reload and stop log statements.
http://people.apache.org/~slaurent/patches/2010-12-16_BZ48822_context_name_on_reload-tc6.patch
Modified:
tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/DefaultServlet.java
URL:
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/DefaultServlet.java?rev=1056775&r1=1056774&r2=1056775&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/DefaultServlet.java
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/DefaultServlet.java
Sat Jan 8 19:27:46 2011
@@ -779,6 +779,13 @@ public class DefaultServlet
}
}
+ boolean isError = false;
+ Integer status =
+ (Integer) request.getAttribute("javax.servlet.error.status_code");
+ if (status != null) {
+ isError = status.intValue() >= HttpServletResponse.SC_BAD_REQUEST;
+ }
+
// Check if the conditions specified in the optional If headers are
// satisfied.
if (cacheEntry.context == null) {
@@ -786,8 +793,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;
}
@@ -815,21 +822,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/tc6.0.x/trunk/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?rev=1056775&r1=1056774&r2=1056775&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Sat Jan 8 19:27:46 2011
@@ -201,6 +201,10 @@
(slaurent)
</add>
<fix>
+ <bug>50413</bug>: Ensure 304s are not returned when using static files
+ as error pages. (markt)
+ </fix>
+ <fix>
<bug>50453</bug>: Correctly handle multiple
<code>X-Forwarded-For</code>
headers in the RemoteIpValve. Patch provided by Jim Riggs. (markt)
</fix>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]