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

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


The following commit(s) were added to refs/heads/11.0.x by this push:
     new 8f8a95e86c Default error responses to HTTP/1.1 if protocol is unknown
8f8a95e86c is described below

commit 8f8a95e86c0ad4af1f63430fe5f5b4139bc2509b
Author: Mark Thomas <[email protected]>
AuthorDate: Thu Nov 19 11:20:46 2026 +0000

    Default error responses to HTTP/1.1 if protocol is unknown
---
 java/org/apache/coyote/http11/Http11Processor.java | 23 ++++++++++++++++------
 webapps/docs/changelog.xml                         |  5 +++++
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/java/org/apache/coyote/http11/Http11Processor.java 
b/java/org/apache/coyote/http11/Http11Processor.java
index 98e8d43a14..e0c46ba332 100644
--- a/java/org/apache/coyote/http11/Http11Processor.java
+++ b/java/org/apache/coyote/http11/Http11Processor.java
@@ -276,13 +276,24 @@ public class Http11Processor extends AbstractProcessor {
 
             // Parsing the request header
             try {
-                if (!inputBuffer.parseRequestLine(keptAlive, 
protocol.getConnectionTimeout(),
-                        protocol.getKeepAliveTimeout())) {
-                    if (inputBuffer.getParsingRequestLinePhase() == -1) {
-                        return SocketState.UPGRADING;
-                    } else if (handleIncompleteRequestLineRead()) {
-                        break;
+                try {
+                    if (!inputBuffer.parseRequestLine(keptAlive, 
protocol.getConnectionTimeout(),
+                            protocol.getKeepAliveTimeout())) {
+                        if (inputBuffer.getParsingRequestLinePhase() == -1) {
+                            return SocketState.UPGRADING;
+                        } else if (handleIncompleteRequestLineRead()) {
+                            break;
+                        }
                     }
+                } catch (Throwable t) {
+                    /*
+                     * Failed to read the request line. The protocol is 
therefore unknown at this point. Need to set
+                     * the protocol before reporting the error.
+                     */
+                    http09 = false;
+                    http11 = true;
+                    // Then re-throw the error
+                    throw t;
                 }
 
                 // Process the Protocol component of the request line
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index ff2dcff6c7..4c91ab620f 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -214,6 +214,11 @@
         connection flow control window reserved for a sendfile response if the
         stream is reset before the response is complete.  (markt)
       </fix>
+      <fix>
+        When an HTTP/1.x request is received with an invalid request line, the
+        client protocol version is unknown. Default to HTTP/1.1 for the error
+        response. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">


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

Reply via email to