tests/http: add HTTP/2 Upgrade and prior knowledge tests

Adds test cases to check that plain http: with HTTP/2 works
via 'Upgrade: h2c' or --http2-prior-knowledge'.

Also added tests to check connection reused in these situations.

Closes #14694
This commit is contained in:
Stefan Eissing 2024-08-26 16:17:45 +02:00 committed by Daniel Stenberg
parent 9280bbea3f
commit 4c744c3ee2
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 48 additions and 1 deletions

View file

@ -116,3 +116,26 @@ class TestBasic:
# 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]}'
# http: GET for HTTP/2, see Upgrade:, 101 switch
def test_01_08_h2_upgrade(self, env: Env, httpd):
curl = CurlClient(env=env)
url = f'http://{env.domain1}:{env.http_port}/data.json'
r = curl.http_get(url=url, extra_args=['--http2'])
r.check_exit_code(0)
assert len(r.responses) == 2, f'{r.responses}'
assert r.responses[0]['status'] == 101, f'{r.responses[0]}'
assert r.responses[1]['status'] == 200, f'{r.responses[1]}'
assert r.responses[1]['protocol'] == 'HTTP/2', f'{r.responses[1]}'
assert r.json['server'] == env.domain1
# http: GET for HTTP/2 with prior knowledge
def test_01_09_h2_prior_knowledge(self, env: Env, httpd):
curl = CurlClient(env=env)
url = f'http://{env.domain1}:{env.http_port}/data.json'
r = curl.http_get(url=url, extra_args=['--http2-prior-knowledge'])
r.check_exit_code(0)
assert len(r.responses) == 1, f'{r.responses}'
assert r.response['status'] == 200, f'{r.responsw}'
assert r.response['protocol'] == 'HTTP/2', f'{r.response}'
assert r.json['server'] == env.domain1