]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
* mod_http2: resurrecting check for nghttp function
authorStefan Eissing <icing@apache.org>
Wed, 13 Oct 2021 12:26:21 +0000 (12:26 +0000)
committerStefan Eissing <icing@apache.org>
Wed, 13 Oct 2021 12:26:21 +0000 (12:26 +0000)
    nghttp2_session_callbacks_set_on_invalid_header_callback
    adding test for proxy server header behaviour
    making test fixture package scoped for better performance

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

modules/http2/h2_proxy_session.c
test/modules/core/conftest.py
test/modules/http2/conftest.py
test/modules/http2/test_501_proxy_serverheader.py [new file with mode: 0644]

index 1cdce4f4275f529786ab247e8a4d7c9b3054548e..dfe3a2c245e21473269e25c6caeff3b4171d0368 100644 (file)
@@ -692,6 +692,7 @@ static ssize_t stream_request_data(nghttp2_session *ngh2, int32_t stream_id,
     }
 }
 
+#ifdef H2_NG2_INVALID_HEADER_CB
 static int on_invalid_header_cb(nghttp2_session *ngh2,
                                 const nghttp2_frame *frame, 
                                 const uint8_t *name, size_t namelen, 
@@ -710,6 +711,7 @@ static int on_invalid_header_cb(nghttp2_session *ngh2,
                                      frame->hd.stream_id, 
                                      NGHTTP2_PROTOCOL_ERROR);
 }
+#endif
 
 h2_proxy_session *h2_proxy_session_setup(const char *id, proxy_conn_rec *p_conn,
                                          proxy_server_conf *conf,
@@ -751,8 +753,9 @@ h2_proxy_session *h2_proxy_session_setup(const char *id, proxy_conn_rec *p_conn,
         nghttp2_session_callbacks_set_on_header_callback(cbs, on_header);
         nghttp2_session_callbacks_set_before_frame_send_callback(cbs, before_frame_send);
         nghttp2_session_callbacks_set_send_callback(cbs, raw_send);
+#ifdef H2_NG2_INVALID_HEADER_CB
         nghttp2_session_callbacks_set_on_invalid_header_callback(cbs, on_invalid_header_cb);
-
+#endif
         nghttp2_option_new(&option);
         nghttp2_option_set_peer_max_concurrent_streams(option, 100);
         nghttp2_option_set_no_auto_window_update(option, 0);
index b0be4af5f4a0b381f1a63eec1f2315192207f56f..e29ebbf15d89d1ee081fb603e4e77d96a396c69d 100644 (file)
@@ -14,7 +14,7 @@ def pytest_report_header(config, startdir):
     return f"core [apache: {env.get_httpd_version()}, mpm: {env.mpm_type}, {env.prefix}]"
 
 
-@pytest.fixture(scope="module")
+@pytest.fixture(scope="package")
 def env(pytestconfig) -> CoreTestEnv:
     level = logging.INFO
     console = logging.StreamHandler()
@@ -28,7 +28,7 @@ def env(pytestconfig) -> CoreTestEnv:
     return env
 
 
-@pytest.fixture(autouse=True, scope="module")
+@pytest.fixture(autouse=True, scope="package")
 def _session_scope(env):
     yield
     assert env.apache_stop() == 0
index 930cc0ac7cecc40767903cb0ec9b65d6c7d73d3c..6946efa4b1c3e1b7135ced45c0809a30effec906 100644 (file)
@@ -27,7 +27,7 @@ def pytest_generate_tests(metafunc):
         metafunc.parametrize('repeat', range(count))
 
 
-@pytest.fixture(scope="module")
+@pytest.fixture(scope="package")
 def env(pytestconfig) -> H2TestEnv:
     level = logging.INFO
     console = logging.StreamHandler()
@@ -41,7 +41,7 @@ def env(pytestconfig) -> H2TestEnv:
     return env
 
 
-@pytest.fixture(autouse=True, scope="module")
+@pytest.fixture(autouse=True, scope="package")
 def _session_scope(env):
     yield
     assert env.apache_stop() == 0
diff --git a/test/modules/http2/test_501_proxy_serverheader.py b/test/modules/http2/test_501_proxy_serverheader.py
new file mode 100644 (file)
index 0000000..1ac7e9a
--- /dev/null
@@ -0,0 +1,35 @@
+import pytest
+
+from .env import H2Conf
+
+
+class TestStore:
+
+    @pytest.fixture(autouse=True, scope='class')
+    def _class_scope(self, env):
+        conf = H2Conf(env)
+        conf.add_vhost_cgi(proxy_self=True, h2proxy_self=False, extras={
+            f'cgi.{env.http_tld}': f"""
+                Header unset Server
+                Header always set Server cgi
+            """
+        })
+        conf.install()
+        assert env.apache_restart() == 0
+
+    def setup_method(self, method):
+        print("setup_method: %s" % method.__name__)
+
+    def teardown_method(self, method):
+        print("teardown_method: %s" % method.__name__)
+
+    def test_h2_501_01(self, env):
+        url = env.mkurl("https", "cgi", "/proxy/hello.py")
+        r = env.curl_get(url, 5)
+        assert 200 == r.response["status"]
+        assert "HTTP/1.1" == r.response["json"]["protocol"]
+        assert "" == r.response["json"]["https"]
+        assert "" == r.response["json"]["ssl_protocol"]
+        assert "" == r.response["json"]["h2"]
+        assert "" == r.response["json"]["h2push"]
+        assert "cgi" == r.response["header"]["server"]