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 a8fcbe5def Default error responses to HTTP/1.1 if protocol is unknown
a8fcbe5def is described below
commit a8fcbe5def37bf097b8b55c92545b7524eed4f0c
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 | 22 ++++++++++++++++------
webapps/docs/changelog.xml | 5 +++++
2 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/java/org/apache/coyote/http11/Http11Processor.java
b/java/org/apache/coyote/http11/Http11Processor.java
index d122f33e9d..8b2931a626 100644
--- a/java/org/apache/coyote/http11/Http11Processor.java
+++ b/java/org/apache/coyote/http11/Http11Processor.java
@@ -270,13 +270,23 @@ 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.
+ */
+ 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 78933bf9a6..2d99b6cfb5 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -352,6 +352,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]