This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push:
new 7db5d81eaa Do not send Early Hints to HTTP/1.0 clients (#1149)
7db5d81eaa is described below
commit 7db5d81eaa904f16f2e8a108f1c1068021107162
Author: Arturo Bernal <[email protected]>
AuthorDate: Fri Nov 13 15:34:11 2026 +0100
Do not send Early Hints to HTTP/1.0 clients (#1149)
RFC 9110, section 15.2 states that, since HTTP/1.0 did not define any
1xx
status codes, a server MUST NOT send a 1xx response to an HTTP/1.0
client.
A 103 response was sent to an HTTP/1.0 client when the application
called
sendEarlyHints(). Skip the early hints for requests that are not
HTTP/1.1.
---
java/org/apache/coyote/http11/Http11Processor.java | 4 +++
.../apache/coyote/http11/TestHttp11Processor.java | 34 ++++++++++++++++++++++
webapps/docs/changelog.xml | 6 ++++
3 files changed, 44 insertions(+)
diff --git a/java/org/apache/coyote/http11/Http11Processor.java
b/java/org/apache/coyote/http11/Http11Processor.java
index 9e03fe73f5..cd76334598 100644
--- a/java/org/apache/coyote/http11/Http11Processor.java
+++ b/java/org/apache/coyote/http11/Http11Processor.java
@@ -1349,6 +1349,10 @@ public class Http11Processor extends AbstractProcessor {
@Override
protected void earlyHints() throws IOException {
+ // A server must not send a 1xx response to an HTTP/1.0 client (RFC
9110, section 15.2)
+ if (!http11) {
+ return;
+ }
writeHeaders(103, response.getMimeHeaders());
outputBuffer.writeHeaders();
outputBuffer.resetHeaderBuffer();
diff --git a/test/org/apache/coyote/http11/TestHttp11Processor.java
b/test/org/apache/coyote/http11/TestHttp11Processor.java
index ede3a14286..5b9a7c459f 100644
--- a/test/org/apache/coyote/http11/TestHttp11Processor.java
+++ b/test/org/apache/coyote/http11/TestHttp11Processor.java
@@ -2149,6 +2149,40 @@ public class TestHttp11Processor extends TomcatBaseTest {
}
+ /*
+ * RFC 9110, section 15.2: a server MUST NOT send a 1xx response to an
HTTP/1.0 client.
+ */
+ @Test
+ public void testEarlyHintsHttp10() throws Exception {
+ Tomcat tomcat = getTomcatInstance();
+
+ // No file system docBase required
+ Context ctx = getProgrammaticRootContext();
+
+ // Add servlet
+ Tomcat.addServlet(ctx, "EarlyHintsServlet", new EarlyHintsServlet());
+ ctx.addServletMapping("/ehs", "EarlyHintsServlet");
+
+ tomcat.start();
+
+ // @formatter:off
+ String request =
+ "GET /ehs HTTP/1.0" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ CRLF;
+ // @formatter:on
+
+ Client client = new Client(tomcat.getConnector().getLocalPort());
+ client.setRequest(new String[] { request });
+
+ client.connect(600000, 600000);
+ client.processRequest(false);
+
+ // The first (and only) response must be the final response
+ Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
+ }
+
+
private static class EarlyHintsServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index e7d43e7963..2cc9be8891 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -160,6 +160,12 @@
read the request line, as required by RFC 9112, section 3. Pull request
<pr>1147</pr> provided by Arturo Bernal. (markt)
</fix>
+ <fix>
+ Do not send a 103 (Early Hints) response to an HTTP/1.0 client as a
+ server must not send a 1xx response to an HTTP/1.0 client. (RFC 9110,
+ section 15.2). Pull request <pr>1149</pr> provided by Arturo Bernal.
+ (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Jasper">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]