]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
tests modules/http1: use "Header add" to produce response headers with whitespace.
authorStefan Eissing <icing@apache.org>
Wed, 19 Oct 2022 09:16:30 +0000 (09:16 +0000)
committerStefan Eissing <icing@apache.org>
Wed, 19 Oct 2022 09:16:30 +0000 (09:16 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1904693 13f79535-47bb-0310-9956-ffa450edef68

test/modules/http1/test_007_strict.py
test/pyhttpd/env.py

index 4649b01123fa29aac50d47573617188e4a1479b2..78182419dc283f8d5b41a6c2995e45ad6d511826 100644 (file)
@@ -67,3 +67,31 @@ class TestRequestStrict:
                     assert int(m.group(1)) == status, f"{rlines}"
                 else:
                     assert int(m.group(1)) >= 400, f"{rlines}"
+
+    @pytest.mark.parametrize(["hvalue", "expvalue"], [
+        ['123', '123'],
+        ['123 ', '123 '],    # trailing space stays
+        ['123\t', '123\t'],    # trailing tab stays
+        [' 123', '123'],    # leading space is stripped
+        ['          123', '123'],  # leading spaces are stripped
+        ['\t123', '123'],  # leading tab is stripped
+    ])
+    def test_h1_007_02(self, env, hvalue, expvalue):
+        hname = 'ap-test-007'
+        conf = H1Conf(env, extras={
+            f'test1.{env.http_tld}': [
+                '<Location />',
+                f'Header add {hname} "{hvalue}"',
+                '</Location>',
+            ]
+        })
+        conf.add_vhost_test1(
+            proxy_self=True
+        )
+        conf.install()
+        assert env.apache_restart() == 0
+        url = env.mkurl("https", "test1", "/")
+        r = env.curl_get(url, options=['--http1.1'])
+        assert r.response["status"] == 200
+        assert r.response["header"][hname] == expvalue
+
index af856effe439458a1590bf9d90bcac03b3def0df..67d32b7b38ae3b296d934077c2608c75fda2b86a 100644 (file)
@@ -739,7 +739,8 @@ class HttpdTestEnv:
             self.curl_parse_headerfile(headerfile, r=r)
             if r.json:
                 r.response["json"] = r.json
-        os.remove(headerfile)
+        if os.path.isfile(headerfile):
+            os.remove(headerfile)
         return r
 
     def curl_get(self, url, insecure=False, options=None):