Skip to content

Commit

Permalink
Add test to validate Request Headers too large fails with 431 status
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalresistor committed Oct 22, 2020
1 parent 4a862fa commit c85f7e3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit c85f7e3

Please sign in to comment.