diff options
author | Stefan Eissing <icing@apache.org> | 2022-09-20 14:40:58 +0200 |
---|---|---|
committer | Stefan Eissing <icing@apache.org> | 2022-09-20 14:40:58 +0200 |
commit | 4ef081eddf3b243bb7f7fbdbf4750b451c052840 (patch) | |
tree | 577e2f6f981d7fab7994635c3af493d36999a75b /test/modules/http2/test_600_h2proxy.py | |
parent | fr doc rebuild. (diff) | |
download | apache2-4ef081eddf3b243bb7f7fbdbf4750b451c052840.tar.xz apache2-4ef081eddf3b243bb7f7fbdbf4750b451c052840.zip |
*) mod_proxy_http2: use only the ':authority' header to forward 'Host'
information to a backend. Deduce ':authority' from what the client
sent when 'ProxyPreserveHost' is on.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1904164 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r-- | test/modules/http2/test_600_h2proxy.py | 53 |
1 files changed, 45 insertions, 8 deletions
diff --git a/test/modules/http2/test_600_h2proxy.py b/test/modules/http2/test_600_h2proxy.py index d27143d22c..0f368eda03 100644 --- a/test/modules/http2/test_600_h2proxy.py +++ b/test/modules/http2/test_600_h2proxy.py @@ -6,16 +6,15 @@ from .env import H2Conf, H2TestEnv @pytest.mark.skipif(condition=H2TestEnv.is_unsupported, reason="mod_http2 not supported here") class TestH2Proxy: - @pytest.fixture(autouse=True, scope='class') - def _class_scope(self, env): - conf = H2Conf(env) + def test_h2_600_01(self, env): + conf = H2Conf(env, extras={ + f'cgi.{env.http_tld}': [ + "SetEnvIf Host (.+) X_HOST=$1", + ] + }) conf.add_vhost_cgi(h2proxy_self=True) - if env.verbosity > 1: - conf.add("LogLevel proxy:trace2 proxy_http2:trace2") conf.install() assert env.apache_restart() == 0 - - def test_h2_600_01(self, env): url = env.mkurl("https", "cgi", "/h2proxy/hello.py") r = env.curl_get(url, 5) assert r.response["status"] == 200 @@ -24,4 +23,42 @@ class TestH2Proxy: assert r.response["json"]["ssl_protocol"] != "" assert r.response["json"]["h2"] == "on" assert r.response["json"]["h2push"] == "off" - assert r.response["json"]["host"] == f"cgi.{env.http_tld}" + assert r.response["json"]["x_host"] == f"cgi.{env.http_tld}:{env.https_port}" + + def test_h2_600_02(self, env): + conf = H2Conf(env, extras={ + f'cgi.{env.http_tld}': [ + "SetEnvIf Host (.+) X_HOST=$1", + f"ProxyPreserveHost on", + f"ProxyPass /h2c/ h2c://127.0.0.1:{env.http_port}/", + ] + }) + conf.add_vhost_cgi() + conf.install() + assert env.apache_restart() == 0 + url = env.mkurl("https", "cgi", "/h2c/hello.py") + r = env.curl_get(url, 5) + assert r.response["status"] == 200 + assert r.response["json"]["protocol"] == "HTTP/2.0" + assert r.response["json"]["https"] == "" + # the proxied backend sees Host header as passed on front + assert r.response["json"]["x_host"] == f"cgi.{env.http_tld}:{env.https_port}" + + def test_h2_600_03(self, env): + conf = H2Conf(env, extras={ + f'cgi.{env.http_tld}': [ + "SetEnvIf Host (.+) X_HOST=$1", + f"ProxyPreserveHost off", + f"ProxyPass /h2c/ h2c://127.0.0.1:{env.http_port}/", + ] + }) + conf.add_vhost_cgi() + conf.install() + assert env.apache_restart() == 0 + url = env.mkurl("https", "cgi", "/h2c/hello.py") + r = env.curl_get(url, 5) + assert r.response["status"] == 200 + assert r.response["json"]["protocol"] == "HTTP/2.0" + assert r.response["json"]["https"] == "" + # the proxied backend sees Host as using in connecting to it + assert r.response["json"]["x_host"] == f"127.0.0.1:{env.http_port}" |