From d94933b89f6cea18ccdda868d6bd81a5811385fc Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Thu, 7 Nov 2024 12:02:41 +0000 Subject: mod_http2, fix keepalive timeout on reset requests Count failed requests that are RST'ed, so that the connection enters keepalive timeout instead of the regular timeout if the first request fails. Add tests to verify. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1921805 13f79535-47bb-0310-9956-ffa450edef68 --- test/modules/http2/test_200_header_invalid.py | 55 +++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'test') diff --git a/test/modules/http2/test_200_header_invalid.py b/test/modules/http2/test_200_header_invalid.py index 04c022c362..cbc4b6c9fa 100644 --- a/test/modules/http2/test_200_header_invalid.py +++ b/test/modules/http2/test_200_header_invalid.py @@ -1,3 +1,4 @@ +import re import pytest from .env import H2Conf, H2TestEnv @@ -227,3 +228,57 @@ class TestInvalidHeaders: r = env.nghttp().get(url, options=opt) assert r.exit_code == 0, r assert r.response is None + + # test few failed headers, should + def test_h2_200_17(self, env): + url = env.mkurl("https", "cgi", "/") + + # test few failed headers, should give response + def test_h2_200_17(self, env): + conf = H2Conf(env) + conf.add(""" + LimitRequestFieldSize 20 + LogLevel http2:debug + """) + conf.add_vhost_cgi() + conf.install() + assert env.apache_restart() == 0 + re_emitted = re.compile(r'.* AH03401: .* shutdown, remote.emitted=1') + url = env.mkurl("https", "cgi", "/") + opt = [] + for i in range(10): + opt += ["-H", f"x{i}: 012345678901234567890123456789"] + r = env.curl_get(url, options=opt) + assert r.response + assert r.response["status"] == 431 + assert env.httpd_error_log.scan_recent(re_emitted) + + # test too many failed headers, should give RST + def test_h2_200_18(self, env): + conf = H2Conf(env) + conf.add(""" + LimitRequestFieldSize 20 + LogLevel http2:debug + """) + conf.add_vhost_cgi() + conf.install() + assert env.apache_restart() == 0 + re_emitted = re.compile(r'.* AH03401: .* shutdown, remote.emitted=1') + url = env.mkurl("https", "cgi", "/") + opt = [] + for i in range(100): + opt += ["-H", f"x{i}: 012345678901234567890123456789"] + r = env.curl_get(url, options=opt) + assert r.response is None + assert env.httpd_error_log.scan_recent(re_emitted) + + # test header 10 invalid headers, should trigger stream RST + def test_h2_200_19(self, env): + url = env.mkurl("https", "cgi", "/") + opt = [] + invalid = '\x7f' + for i in range(10): + opt += ["-H", f"x{i}: {invalid}"] + r = env.curl_get(url, options=opt) + assert r.response is None + -- cgit v1.2.3