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

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


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

commit b192ed6c995ce32bc60605435d3c7c0ab7ee5c18
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 8a12bb8616..e4b8396231 100644
--- a/java/org/apache/coyote/http11/Http11Processor.java
+++ b/java/org/apache/coyote/http11/Http11Processor.java
@@ -277,13 +277,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 6d2c8f57c0..a00eface99 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