]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
*) mod_http2: avoid double chunked-encoding on internal redirects.
authorStefan Eissing <icing@apache.org>
Fri, 19 May 2023 12:17:44 +0000 (12:17 +0000)
committerStefan Eissing <icing@apache.org>
Fri, 19 May 2023 12:17:44 +0000 (12:17 +0000)
     PR 66597 [Yann Ylavic, Stefan Eissing]

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1909932 13f79535-47bb-0310-9956-ffa450edef68

changes-entries/pr66597.txt [new file with mode: 0644]
modules/http2/h2_c2.c
test/modules/http2/htdocs/cgi/xxx/test.json [new file with mode: 0644]
test/modules/http2/test_004_post.py

diff --git a/changes-entries/pr66597.txt b/changes-entries/pr66597.txt
new file mode 100644 (file)
index 0000000..958af0f
--- /dev/null
@@ -0,0 +1,2 @@
+  *) mod_http2: avoid double chunked-encoding on internal redirects.
+     PR 66597 [Yann Ylavic, Stefan Eissing]
index c06438ecff1c93fa303a3777901be3609b083a27..0c2edba55bf14f59e4f8f34cce06a5a63f5f5613 100644 (file)
@@ -806,7 +806,7 @@ static int h2_c2_hook_post_read_request(request_rec *r)
 {
     h2_conn_ctx_t *conn_ctx = h2_conn_ctx_get(r->connection);
 
-    if (conn_ctx && conn_ctx->stream_id) {
+    if (conn_ctx && conn_ctx->stream_id && ap_is_initial_req(r)) {
 
         ap_log_rerror(APLOG_MARK, APLOG_TRACE3, 0, r,
                       "h2_c2(%s-%d): adding request filters",
diff --git a/test/modules/http2/htdocs/cgi/xxx/test.json b/test/modules/http2/htdocs/cgi/xxx/test.json
new file mode 100644 (file)
index 0000000..ceafd0a
--- /dev/null
@@ -0,0 +1 @@
+{"name": "test.json"}
\ No newline at end of file
index 2daa6ffdbbe7af1f2f15c627a2fe97e9292e57f0..295f989b88ec36a034251e5bb4c622740c3a3f85 100644 (file)
@@ -18,7 +18,15 @@ class TestPost:
     @pytest.fixture(autouse=True, scope='class')
     def _class_scope(self, env):
         TestPost._local_dir = os.path.dirname(inspect.getfile(TestPost))
-        H2Conf(env).add_vhost_cgi().install()
+        conf = H2Conf(env, extras={
+            f'cgi.{env.http_tld}': [
+                f'<Directory {env.server_docs_dir}/cgi/xxx>',
+                '  RewriteEngine On',
+                '  RewriteRule .* /proxy/echo.py [QSA]',
+                '</Directory>',
+            ]
+        })
+        conf.add_vhost_cgi(proxy_self=True).install()
         assert env.apache_restart() == 0
 
     def local_src(self, fname):
@@ -179,3 +187,15 @@ class TestPost:
             assert src == filepart.get_payload(decode=True)
         
         post_and_verify("data-1k", [])
+
+    def test_h2_004_41(self, env):
+        # reproduce PR66597, double chunked encoding on redirects
+        url = env.mkurl("https", "cgi", "/xxx/test.json")
+        r = env.curl_post_data(url, data="0123456789", options=[])
+        assert r.exit_code == 0
+        assert 200 <= r.response["status"] < 300
+        assert r.response['body'] == b'0123456789'
+        r = env.curl_post_data(url, data="0123456789", options=["-H", "Content-Length:"])
+        assert r.exit_code == 0
+        assert 200 <= r.response["status"] < 300
+        assert r.response['body'] == b'0123456789'