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 34cba496f4 Do not send Early Hints to HTTP/1.0 clients (#1149)
34cba496f4 is described below

commit 34cba496f4f2c1c45ad908b33b8e2b92220a5b68
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 1c9f16cd8a..8a12bb8616 100644
--- a/java/org/apache/coyote/http11/Http11Processor.java
+++ b/java/org/apache/coyote/http11/Http11Processor.java
@@ -1348,6 +1348,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 8ac68c1541..0483285ee1 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 22274f7730..b1e303df43 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]

Reply via email to