From c85f7e3ce2bfa6024b0ac8b3cefcb2b206f5e047 Mon Sep 17 00:00:00 2001 From: Bert JW Regeer Date: Wed, 21 Oct 2020 21:28:00 -0700 Subject: [PATCH] Add test to validate Request Headers too large fails with 431 status --- tests/test_functional.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_functional.py b/tests/test_functional.py index a52d256f..25b194f4 100644 --- a/tests/test_functional.py +++ b/tests/test_functional.py @@ -879,6 +879,20 @@ def setUp(self): def tearDown(self): self.stop_subprocess() + def test_request_headers_too_large_http11(self): + body = b"" + bad_headers = b"X-Random-Header: 100\r\n" * int(self.toobig / 20) + to_send = b"GET / HTTP/1.1\r\nContent-Length: 0\r\n" + to_send += bad_headers + to_send += b"\r\n\r\n" + to_send += body + self.connect() + self.sock.send(to_send) + fp = self.sock.makefile("rb") + response_line, headers, response_body = read_http(fp) + self.assertline(response_line, "431", "Request Header Fields Too Large", "HTTP/1.0") + self.assertEqual(headers['connection'], "close") + def test_request_body_too_large_with_wrong_cl_http10(self): body = b"a" * self.toobig to_send = b"GET / HTTP/1.0\r\nContent-Length: 5\r\n\r\n"