diff --git a/test/modules/http2/test_008_ranges.py b/test/modules/http2/test_008_ranges.py index 070dd389715..9408b5132ca 100644 --- a/test/modules/http2/test_008_ranges.py +++ b/test/modules/http2/test_008_ranges.py @@ -181,6 +181,17 @@ def test_h2_008_04(self, env, repeat): assert (4*count)+1 <= int(stats['Total kBytes']), f'{stats}' assert (4*(count+1))+1 + polled_kb > int(stats['Total kBytes']), f'{stats}' + # A paced download of the whole resource: flow control and + # buffering must still deliver it complete. + def test_h2_008_05_throttled_download(self, env): + url = env.mkurl("https", "test1", '/data-100k?05throttled') + r = env.curl_get(url, 5, options=[ + '--limit-rate', '64k', + ]) + assert r.exit_code == 0, f'{r}' + assert r.response["status"] == 200 + assert 100*1000 == len(r.response["body"]) + def get_server_status(self, env): status_url = env.mkurl("https", "test1", '/status?auto') r = env.curl_get(status_url, 5) diff --git a/test/modules/http2/test_105_timeout.py b/test/modules/http2/test_105_timeout.py index 088f2e1c6d0..fd3f9fef844 100644 --- a/test/modules/http2/test_105_timeout.py +++ b/test/modules/http2/test_105_timeout.py @@ -166,3 +166,25 @@ def test_h2_105_12(self, env): piper.close() assert piper.response, f'{piper}' assert piper.response['status'] == 408, f"{piper.response}" + + # A client which gives up on a slow response (curl --max-time) resets + # the stream; the session and the server must stay healthy. + def test_h2_105_13_client_cancel_slow_response(self, env): + conf = H2Conf(env) + conf.add_vhost_cgi() + conf.install() + assert env.apache_restart() == 0 + url = env.mkurl("https", "cgi", "/necho.py") + r = env.curl_raw([url], options=[ + '-F', 'count=50000', + '-F', 'text=abcdefghij', + '-F', 'wait2=2', + '--max-time', '1', + ]) + # necho.py waits before the body, so the client always gives + # up first: curl exit code 28 is the timeout. + assert r.exit_code == 28 + # the server is still responsive after the cancellation + r = env.curl_get(env.mkurl("https", "cgi", "/hello.py")) + assert r.exit_code == 0 + assert r.response["status"] == 200 diff --git a/test/modules/http2/test_200_header_invalid.py b/test/modules/http2/test_200_header_invalid.py index 32d492c287b..2453b82a05f 100644 --- a/test/modules/http2/test_200_header_invalid.py +++ b/test/modules/http2/test_200_header_invalid.py @@ -292,3 +292,52 @@ def test_h2_200_19(self, env): r = env.curl_get(url, options=opt) assert r.response is None + +# Header *values* of zero length, with the default limits in effect (the +# class above installs small LimitRequest* values per test and leaves +# them behind, which would fail these on their own). +class TestEmptyHeaderValues: + + @pytest.fixture(autouse=True, scope='class') + @classmethod + def _class_scope(cls, env): + H2Conf(env).add_vhost_cgi().install() + assert env.apache_restart() == 0 + + # A header with a zero-length value is valid h2 (and valid HTTP): + # the request must be served, and the header must arrive. curl + # removes a header given as "-H 'X:'"; the "-H 'X;'" form sends it + # with an empty value, and hecho.py echoes it back. + def test_h2_200_20_single_empty_value(self, env): + url = env.mkurl("https", "cgi", "/hecho.py") + r = env.curl_post_data(url, "name=X_EMPTY_VALUE", + options=['-H', 'X-Empty-Value;']) + assert r.exit_code == 0 + assert r.response["status"] == 200 + assert r.response["header"].get("x_empty_value") == "" + + # Several zero-length values mixed with non-empty ones: also served, + # and the empty one still arrives. + def test_h2_200_21_mixed_empty_and_nonempty(self, env): + url = env.mkurl("https", "cgi", "/hecho.py") + r = env.curl_post_data(url, "name=X_EMPTY_ONE", + options=['-H', 'X-Has-Value: something', + '-H', 'X-Empty-One;', + '-H', 'X-Also-Has-Value: else']) + assert r.exit_code == 0 + assert r.response["status"] == 200 + assert r.response["header"].get("x_empty_one") == "" + + # Repeatedly sending zero-length values must leave the session and + # the server healthy. + def test_h2_200_22_repeated_empty_values(self, env): + url = env.mkurl("https", "cgi", "/hecho.py") + for i in range(10): + r = env.curl_post_data(url, f"name=X_EMPTY_{i}", + options=['-H', f'X-Empty-{i};']) + assert r.exit_code == 0 + assert r.response["status"] == 200 + assert r.response["header"].get(f"x_empty_{i}") == "" + r = env.curl_get(env.mkurl("https", "cgi", "/hello.py")) + assert r.exit_code == 0 + assert r.response["status"] == 200