This is an automated email from the ASF dual-hosted git repository.

markt-asf pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new 7eaf234c61 Follow-up to PR #1147
7eaf234c61 is described below

commit 7eaf234c61969cf61cec5a94e8f5fa5ebcdc4bfd
Author: Mark Thomas <[email protected]>
AuthorDate: Fri Nov 13 12:38:43 2026 +0000

    Follow-up to PR #1147
---
 java/org/apache/coyote/http11/Http11Processor.java     |  6 ++++--
 .../coyote/http11/RequestTargetTooLongException.java   |  2 --
 .../apache/coyote/http11/TestHttp11InputBuffer.java    | 18 ++++++------------
 webapps/docs/changelog.xml                             |  3 ++-
 4 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/java/org/apache/coyote/http11/Http11Processor.java 
b/java/org/apache/coyote/http11/Http11Processor.java
index 6981d4541e..28036f055f 100644
--- a/java/org/apache/coyote/http11/Http11Processor.java
+++ b/java/org/apache/coyote/http11/Http11Processor.java
@@ -309,6 +309,9 @@ public class Http11Processor extends AbstractProcessor {
                 }
                 setErrorState(ErrorState.CLOSE_CONNECTION_NOW, ioe);
                 break;
+            } catch (RequestTargetTooLongException e) {
+                
response.setStatus(HttpServletResponse.SC_REQUEST_URI_TOO_LONG);
+                setErrorState(ErrorState.CLOSE_CLEAN, e);
             } catch (Throwable t) {
                 ExceptionUtils.handleThrowable(t);
                 UserDataHelper.Mode logMode = userDataHelper.getNextMode();
@@ -325,8 +328,7 @@ public class Http11Processor extends AbstractProcessor {
                             log.debug(message, t);
                     }
                 }
-                // 414 - URI Too Long (RFC 9112, section 3) or 400 - Bad 
Request
-                response.setStatus(t instanceof RequestTargetTooLongException 
? 414 : 400);
+                response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
                 setErrorState(ErrorState.CLOSE_CLEAN, t);
             }
 
diff --git a/java/org/apache/coyote/http11/RequestTargetTooLongException.java 
b/java/org/apache/coyote/http11/RequestTargetTooLongException.java
index 51e05086e8..11b7907a29 100644
--- a/java/org/apache/coyote/http11/RequestTargetTooLongException.java
+++ b/java/org/apache/coyote/http11/RequestTargetTooLongException.java
@@ -21,8 +21,6 @@ import java.io.Serial;
 /**
  * Exception used to mark the specific error condition of the request target 
exceeding the size of the buffer used to
  * read the request line.
- *
- * @since 12.0.x
  */
 public class RequestTargetTooLongException extends IllegalArgumentException {
 
diff --git a/test/org/apache/coyote/http11/TestHttp11InputBuffer.java 
b/test/org/apache/coyote/http11/TestHttp11InputBuffer.java
index 3c4eedba9d..b8a35024b0 100644
--- a/test/org/apache/coyote/http11/TestHttp11InputBuffer.java
+++ b/test/org/apache/coyote/http11/TestHttp11InputBuffer.java
@@ -803,10 +803,8 @@ public class TestHttp11InputBuffer extends TomcatBaseTest {
         LongRequestClient client = new LongRequestClient("/test/" + 
"a".repeat(9000), "X-Test: a");
 
         Exception e = client.doRequest();
-        if (e == null) {
-            Assert.assertTrue(client.getResponseLine(), 
client.isResponse414());
-        }
-        Assert.assertFalse(client.isResponseBodyOK());
+        Assert.assertNull(e);
+        Assert.assertTrue(client.getResponseLine(), client.isResponse414());
     }
 
 
@@ -815,10 +813,8 @@ public class TestHttp11InputBuffer extends TomcatBaseTest {
         LongRequestClient client = new LongRequestClient("/test?q=" + 
"a".repeat(9000), "X-Test: a");
 
         Exception e = client.doRequest();
-        if (e == null) {
-            Assert.assertTrue(client.getResponseLine(), 
client.isResponse414());
-        }
-        Assert.assertFalse(client.isResponseBodyOK());
+        Assert.assertNull(e);
+        Assert.assertTrue(client.getResponseLine(), client.isResponse414());
     }
 
 
@@ -830,10 +826,8 @@ public class TestHttp11InputBuffer extends TomcatBaseTest {
         LongRequestClient client = new LongRequestClient("/test", "X-Test: " + 
"a".repeat(9000));
 
         Exception e = client.doRequest();
-        if (e == null) {
-            Assert.assertTrue(client.getResponseLine(), 
client.isResponse400());
-        }
-        Assert.assertFalse(client.isResponseBodyOK());
+        Assert.assertNull(e);
+        Assert.assertTrue(client.getResponseLine(), client.isResponse400());
     }
 
 
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 35895d7aac..6f60da9540 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -287,7 +287,8 @@
       <fix>
         Respond with a 414 (URI Too Long) status rather than a 400 (Bad 
Request)
         status when the request target is too long to fit in the buffer used to
-        read the request line, as required by RFC 9112, section 3. (abernal)
+        read the request line, as required by RFC 9112, section 3. Pull request
+        <pr>1147</pr> provided by Arturo Bernal. (markt)
       </fix>
     </changelog>
   </subsection>


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to