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

dsoumis 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 ded9b47cc1 Fix BZ 69918 - Ensure request parameters are correctly 
parsed for HTTP/2 requests when the content-length header is not set.
ded9b47cc1 is described below

commit ded9b47cc1bc128ccf8a7320a7621bc2075b81a6
Author: Dimitrios Soumis <[email protected]>
AuthorDate: Mon Jan 12 12:56:58 2026 +0200

    Fix BZ 69918 - Ensure request parameters are correctly parsed for HTTP/2 
requests when the content-length header is not set.
---
 java/org/apache/catalina/connector/Request.java    |  3 +-
 .../coyote/http2/TestHttp2RequestParameters.java   | 52 ++++++++++++++++++++++
 webapps/docs/changelog.xml                         |  4 ++
 3 files changed, 58 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/connector/Request.java 
b/java/org/apache/catalina/connector/Request.java
index 70ac51080f..b9b3857531 100644
--- a/java/org/apache/catalina/connector/Request.java
+++ b/java/org/apache/catalina/connector/Request.java
@@ -3125,7 +3125,8 @@ public class Request implements HttpServletRequest {
                     return;
                 }
                 parameters.processParameters(formData, 0, len);
-            } else if 
("chunked".equalsIgnoreCase(coyoteRequest.getHeader("transfer-encoding"))) {
+            } else if (coyoteRequest.protocol().equals("HTTP/2.0")
+                || 
"chunked".equalsIgnoreCase(coyoteRequest.getHeader("transfer-encoding"))) {
                 byte[] formData = null;
                 try {
                     formData = readChunkedPostBody();
diff --git a/test/org/apache/coyote/http2/TestHttp2RequestParameters.java 
b/test/org/apache/coyote/http2/TestHttp2RequestParameters.java
new file mode 100644
index 0000000000..9dbc332461
--- /dev/null
+++ b/test/org/apache/coyote/http2/TestHttp2RequestParameters.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.coyote.http2;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.apache.catalina.connector.Request;
+
+public class TestHttp2RequestParameters extends Http2TestBase {
+    /**
+     * Test case for https://bz.apache.org/bugzilla/show_bug.cgi?id=69918 POST 
parameters are not returned from a call
+     * to any of the {@link Request} getParameterXXX() methods if the request 
is HTTP/2 and the
+     * content-length header is not set.
+     */
+    @Test
+    public void testBug69918() throws Exception {
+        http2Connect();
+
+        sendParameterPostRequest(3, null, "a=1&b=2", -1, false);
+        output.setTraceBody(true);
+
+        boolean foundBody = false;
+        while (parser.readFrame()) {
+            String trace = output.getTrace();
+            if (trace.contains("3-Body-2")) {
+                foundBody = true;
+            } else if (trace.contains("3-Body-0")) {
+                Assert.fail("Parameter count was 0. Trace: " + trace);
+            }
+            if (trace.contains("3-EndOfStream")) {
+                break;
+            }
+        }
+        Assert.assertTrue("Parameter count should be 2, trace: " + 
output.getTrace(), foundBody);
+    }
+}
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 60b2091186..fa576fd5e5 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -117,6 +117,10 @@
         Pull request <pr>923</pr>: Avoid adding multiple CSRF tokens to a URL 
in
         the <code>CsrfPreventionFilter</code>. (schultz)
       </fix>
+      <fix>
+        <bug>69918</bug>: Ensure request parameters are correctly parsed for 
HTTP/2 requests
+        when the content-length header is not set. (dsoumis)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to