Author: markt
Date: Mon Apr 30 10:57:27 2018
New Revision: 1830547

URL: http://svn.apache.org/viewvc?rev=1830547&view=rev
Log:
Correct a regression in the error page handling that prevented error pages from 
issuing redirects or taking other action that required the response status code 
to be changed.

Modified:
    tomcat/trunk/java/org/apache/coyote/Response.java
    tomcat/trunk/java/org/apache/coyote/http11/Http11InputBuffer.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/coyote/Response.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/Response.java?rev=1830547&r1=1830546&r2=1830547&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/Response.java (original)
+++ tomcat/trunk/java/org/apache/coyote/Response.java Mon Apr 30 10:57:27 2018
@@ -227,10 +227,6 @@ public final class Response {
      * @param status The status value to set
      */
     public void setStatus(int status) {
-        if (this.status > 399) {
-            // Don't overwrite first recorded error status
-            return;
-        }
         this.status = status;
     }
 

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11InputBuffer.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11InputBuffer.java?rev=1830547&r1=1830546&r2=1830547&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11InputBuffer.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11InputBuffer.java Mon Apr 
30 10:57:27 2018
@@ -409,6 +409,8 @@ public class Http11InputBuffer implement
                             pos - parsingRequestLineStart);
                 } else if (!HttpParser.isToken(chr)) {
                     byteBuffer.position(byteBuffer.position() - 1);
+                    // Avoid unknown protocol triggering an additional error
+                    request.protocol().setString(Constants.HTTP_11);
                     throw new 
IllegalArgumentException(sm.getString("iib.invalidmethod"));
                 }
             }
@@ -459,9 +461,13 @@ public class Http11InputBuffer implement
                 } else if (chr == Constants.QUESTION && parsingRequestLineQPos 
== -1) {
                     parsingRequestLineQPos = pos;
                 } else if (parsingRequestLineQPos != -1 && 
!httpParser.isQueryRelaxed(chr)) {
+                    // Avoid unknown protocol triggering an additional error
+                    request.protocol().setString(Constants.HTTP_11);
                     // %nn decoding will be checked at the point of decoding
                     throw new 
IllegalArgumentException(sm.getString("iib.invalidRequestTarget"));
                 } else if (httpParser.isNotRequestTargetRelaxed(chr)) {
+                    // Avoid unknown protocol triggering an additional error
+                    request.protocol().setString(Constants.HTTP_11);
                     // This is a general check that aims to catch problems 
early
                     // Detailed checking of each part of the request target 
will
                     // happen in Http11Processor#prepareRequest()

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1830547&r1=1830546&r2=1830547&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Mon Apr 30 10:57:27 2018
@@ -45,6 +45,13 @@
   issues do not "pop up" wrt. others).
 -->
 <section name="Tomcat 9.0.9 (markt)" rtext="in development">
+  <section name="Coyote">
+    <changelog>
+      Correct a regression in the error page handling that prevented error 
pages
+      from issuing redirects or taking other action that required the response
+      status code to be changed. (markt)
+    </changelog>
+  </section>
 </section>
 <section name="Tomcat 9.0.8 (markt)" rtext="release in progress">
   <subsection name="Catalina">



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

Reply via email to