mirror of
https://github.com/lexmount/moli.git
synced 2026-10-08 00:01:00 +00:00
fix(benchmark): match wptserve HTTP header count limit
Use the upstream fixture server limit of 512 header lines so requests with all 253 valid header values can reach the handler instead of receiving HTTP 431. Cover complete GET/POST header round trips and retain count and line-length bounds. Validation: all 596 benchmark Python tests pass; Moli passes all 537 Headers WPT subtests. Both engines pass all 105 header value and normalization subtests, with Chromium's 24 unrelated failures unchanged.
This commit is contained in:
@@ -84,6 +84,29 @@ class FetchHeaderFixtureTests(unittest.TestCase):
|
||||
self.assertIn(b"Connection: close\r\n", head + b"\r\n")
|
||||
self.assertEqual(body, b"")
|
||||
|
||||
def test_can_send_and_receive_all_253_header_values(self) -> None:
|
||||
request_headers = {
|
||||
f"val{byte}": "x" + chr(byte) + "x"
|
||||
for byte in range(256) if byte not in (0, 10, 13)
|
||||
}
|
||||
for method in ("GET", "POST"):
|
||||
with self.subTest(method=method):
|
||||
status, headers, body = self.request(
|
||||
method, "headers=" + "|".join(request_headers), request_headers
|
||||
)
|
||||
self.assertEqual((status, body), (200, b""))
|
||||
for name, value in request_headers.items():
|
||||
self.assertEqual(headers["x-request-" + name], value, name)
|
||||
|
||||
def test_header_count_and_line_length_remain_bounded(self) -> None:
|
||||
for request_headers in (
|
||||
{f"val{index}": "value" for index in range(512)},
|
||||
{"X-Long": "x" * (64 * 1024)},
|
||||
):
|
||||
with self.subTest(header_count=len(request_headers)):
|
||||
status, _, _ = self.request("GET", "", request_headers)
|
||||
self.assertEqual(status, 431)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user