This is an automated email from the ASF dual-hosted git repository.
markt 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 31db6985a9 Remove HTTP 0.9 support
31db6985a9 is described below
commit 31db6985a96bfe8cabe2c016d98bc36a62b812e6
Author: Mark Thomas <[email protected]>
AuthorDate: Wed Nov 26 16:27:27 2025 +0000
Remove HTTP 0.9 support
---
.../apache/coyote/http11/Http11InputBuffer.java | 24 -----------
java/org/apache/coyote/http11/Http11Processor.java | 49 +++++-----------------
.../TestAsyncContextImplListenerOnComplete.java | 3 +-
.../coyote/http11/TestHttp11InputBufferCRLF.java | 17 --------
webapps/docs/changelog.xml | 3 ++
5 files changed, 15 insertions(+), 81 deletions(-)
diff --git a/java/org/apache/coyote/http11/Http11InputBuffer.java
b/java/org/apache/coyote/http11/Http11InputBuffer.java
index dc1d30ac85..09bb0ed741 100644
--- a/java/org/apache/coyote/http11/Http11InputBuffer.java
+++ b/java/org/apache/coyote/http11/Http11InputBuffer.java
@@ -428,34 +428,10 @@ public class Http11InputBuffer implements InputBuffer,
ApplicationBufferHandler,
}
}
int pos = byteBuffer.position();
- prevChr = chr;
chr = byteBuffer.get();
- if (prevChr == Constants.CR && chr != Constants.LF) {
- // CR not followed by LF so not an HTTP/0.9 request and
- // therefore invalid. Trigger error handling.
- // Avoid unknown protocol triggering an additional error
- request.protocol().setString(Constants.HTTP_11);
- String invalidRequestTarget =
parseInvalid(parsingRequestLineStart, byteBuffer);
- throw new
IllegalArgumentException(sm.getString("iib.invalidRequestTarget",
invalidRequestTarget));
- }
if (chr == Constants.SP || chr == Constants.HT) {
space = true;
end = pos;
- } else if (chr == Constants.CR) {
- // HTTP/0.9 style request. CR is optional. LF is not.
- } else if (chr == Constants.LF) {
- // HTTP/0.9 style request
- // Stop this processing loop
- space = true;
- // Set blank protocol (indicates HTTP/0.9)
- request.protocol().setString("");
- // Skip the protocol processing
- parsingRequestLinePhase = 7;
- if (prevChr == Constants.CR) {
- end = pos - 1;
- } else {
- end = pos;
- }
} else if (chr == Constants.QUESTION && parsingRequestLineQPos
== -1) {
parsingRequestLineQPos = pos;
} else if (parsingRequestLineQPos != -1 &&
!httpParser.isQueryRelaxed(chr)) {
diff --git a/java/org/apache/coyote/http11/Http11Processor.java
b/java/org/apache/coyote/http11/Http11Processor.java
index 19a6bbdcc0..73ffbad3be 100644
--- a/java/org/apache/coyote/http11/Http11Processor.java
+++ b/java/org/apache/coyote/http11/Http11Processor.java
@@ -124,12 +124,6 @@ public class Http11Processor extends AbstractProcessor {
private boolean http11 = true;
- /**
- * HTTP/0.9 flag.
- */
- private boolean http09 = false;
-
-
/**
* Content delimiter for the request (if false, the connection will be
closed at the end of the request).
*/
@@ -289,8 +283,7 @@ public class Http11Processor extends AbstractProcessor {
keptAlive = true;
// Set this every time in case limit has been changed via
JMX
request.getMimeHeaders().setLimit(protocol.getMaxHeaderCount());
- // Don't parse headers for HTTP/0.9
- if (!http09 && !inputBuffer.parseHeaders()) {
+ if (!inputBuffer.parseHeaders()) {
// We've read part of the request, don't recycle it
// instead associate it with the socket
openSocket = true;
@@ -594,27 +587,14 @@ public class Http11Processor extends AbstractProcessor {
MessageBytes protocolMB = request.protocol();
if (protocolMB.equals(Constants.HTTP_11)) {
- http09 = false;
http11 = true;
protocolMB.setString(Constants.HTTP_11);
} else if (protocolMB.equals(Constants.HTTP_10)) {
- http09 = false;
http11 = false;
keepAlive = false;
protocolMB.setString(Constants.HTTP_10);
- } else if (protocolMB.equals("")) {
- // HTTP/0.9
- http09 = true;
- http11 = false;
- keepAlive = false;
- if (!Method.GET.equals(request.getMethod())) {
- // Send 400, GET is the only allowed method for HTTP/0.9
- response.setStatus(400);
- setErrorState(ErrorState.CLOSE_CLEAN, null);
- }
} else {
// Unsupported protocol
- http09 = false;
http11 = false;
// Send 505; Unsupported HTTP version
response.setStatus(505);
@@ -807,18 +787,16 @@ public class Http11Processor extends AbstractProcessor {
// Parse transfer-encoding header
// HTTP specs say an HTTP 1.1 server should accept any recognised
// HTTP 1.x header from a 1.x client unless the specs says otherwise.
- if (!http09) {
- MessageBytes transferEncodingValueMB =
headers.getValue("transfer-encoding");
- if (transferEncodingValueMB != null) {
- List<String> encodingNames = new ArrayList<>();
- if
(TokenList.parseTokenList(headers.values("transfer-encoding"), encodingNames)) {
- for (String encodingName : encodingNames) {
- addInputFilter(inputFilters, encodingName);
- }
- } else {
- // Invalid transfer encoding
-
badRequest("http11processor.request.invalidTransferEncoding");
+ MessageBytes transferEncodingValueMB =
headers.getValue("transfer-encoding");
+ if (transferEncodingValueMB != null) {
+ List<String> encodingNames = new ArrayList<>();
+ if (TokenList.parseTokenList(headers.values("transfer-encoding"),
encodingNames)) {
+ for (String encodingName : encodingNames) {
+ addInputFilter(inputFilters, encodingName);
}
+ } else {
+ // Invalid transfer encoding
+ badRequest("http11processor.request.invalidTransferEncoding");
}
}
@@ -874,13 +852,6 @@ public class Http11Processor extends AbstractProcessor {
OutputFilter[] outputFilters = outputBuffer.getFilters();
- if (http09) {
- // HTTP/0.9
-
outputBuffer.addActiveFilter(outputFilters[Constants.IDENTITY_FILTER]);
- outputBuffer.commit();
- return;
- }
-
int statusCode = response.getStatus();
if (statusCode < 200 || statusCode == 204 || statusCode == 205 ||
statusCode == 304) {
// No entity body
diff --git
a/test/org/apache/catalina/core/TestAsyncContextImplListenerOnComplete.java
b/test/org/apache/catalina/core/TestAsyncContextImplListenerOnComplete.java
index 8233545050..aca065fff5 100644
--- a/test/org/apache/catalina/core/TestAsyncContextImplListenerOnComplete.java
+++ b/test/org/apache/catalina/core/TestAsyncContextImplListenerOnComplete.java
@@ -98,7 +98,8 @@ public class TestAsyncContextImplListenerOnComplete extends
TomcatBaseTest {
try (var writer = new
OutputStreamWriter(socket.getOutputStream())) {
// @formatter:off
writer.write(
- "GET /repro" + CRLF +
+ "GET /repro HTTP/1.1" + CRLF +
+ "Host: localhost:" + port + CRLF +
"Accept: text/event-stream" + CRLF +
CRLF);
// @formatter:on
diff --git a/test/org/apache/coyote/http11/TestHttp11InputBufferCRLF.java
b/test/org/apache/coyote/http11/TestHttp11InputBufferCRLF.java
index d87bfa2cfa..2c9ac6dea5 100644
--- a/test/org/apache/coyote/http11/TestHttp11InputBufferCRLF.java
+++ b/test/org/apache/coyote/http11/TestHttp11InputBufferCRLF.java
@@ -48,23 +48,6 @@ public class TestHttp11InputBufferCRLF extends
TomcatBaseTest {
"GET\t/test\tHTTP/1.1" + CRLF + "Host: localhost:8080" + CRLF
+ "Connection: close" + CRLF + CRLF },
Boolean.TRUE });
- // Requests to simulate package boundaries
- // HTTP/0.9 request
- addRequestWithSplits("GET /test" + CRLF, Boolean.TRUE, parameterSets);
-
- // HTTP/0.9 request with space
- // Either malformed but acceptable HTTP/0.9 or invalid HTTP/1.1
- // Tomcat opts for invalid HTTP/1.1
- addRequestWithSplits("GET /test " + CRLF, Boolean.FALSE,
Boolean.FALSE, parameterSets);
-
- // HTTP/0.9 request (no optional CR)
- addRequestWithSplits("GET /test" + LF, Boolean.TRUE, parameterSets);
-
- // HTTP/0.9 request with space (no optional CR)
- // Either malformed but acceptable HTTP/0.9 or invalid HTTP/1.1
- // Tomcat opts for invalid HTTP/1.1
- addRequestWithSplits("GET /test " + LF, Boolean.FALSE, Boolean.FALSE,
parameterSets);
-
// Standard HTTP/1.1 request
addRequestWithSplits(
"GET /test HTTP/1.1" + CRLF + "Host: localhost:8080" + CRLF +
"Connection: close" + CRLF + CRLF,
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 831024fffd..417a9e9427 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -229,6 +229,9 @@
allowing to restrict which groups can be enabled on the SSL engine.
(remm)
</update>
+ <update>
+ Remove support for HTTP 0.9. (markt)
+ </update>
<!-- Entries for backport and removal before 12.0.0-M1 below this line
-->
<fix>
Don't log an incorrect certificate <code>KeyStore</code> location when
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]