]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
pytests: add tests for HEAD requests in all HTTP versions
authorStefan Eissing <stefan@eissing.org>
Sat, 3 Aug 2024 10:46:28 +0000 (12:46 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 3 Aug 2024 22:20:14 +0000 (00:20 +0200)
Closes #14367

tests/http/test_01_basic.py

index 54e7dd4a70706851d176ae7f8ef684e0050c7e2c..ef62ba40f01056d46e39d410e1ae67f67d1937fa 100644 (file)
@@ -97,3 +97,18 @@ class TestBasic:
         r.check_stats(http_status=200, count=1)
         assert r.stats[0]['time_connect'] > 0, f'{r.stats[0]}'
         assert r.stats[0]['time_appconnect'] > 0, f'{r.stats[0]}'
+
+    # simple https: HEAD
+    @pytest.mark.parametrize("proto", ['http/1.1', 'h2', 'h3'])
+    @pytest.mark.skipif(condition=not Env.have_ssl_curl(), reason=f"curl without SSL")
+    def test_01_07_head(self, env: Env, httpd, nghttpx, repeat, proto):
+        if proto == 'h3' and not env.have_h3():
+            pytest.skip("h3 not supported")
+        curl = CurlClient(env=env)
+        url = f'https://{env.authority_for(env.domain1, proto)}/data.json'
+        r = curl.http_download(urls=[url], with_stats=True, with_headers=True,
+                               extra_args=['-I'])
+        r.check_stats(http_status=200, count=1, exitcode=0)
+        # got the Conten-Length: header, but did not download anything
+        assert r.responses[0]['header']['content-length'] == '30', f'{r.responses[0]}'
+        assert r.stats[0]['size_download'] == 0, f'{r.stats[0]}'