(self)
| 405 | resp.begin(_max_headers=max_headers) |
| 406 | |
| 407 | def test_max_connection_headers(self): |
| 408 | max_headers = client._MAXHEADERS + 20 |
| 409 | headers = ( |
| 410 | f"Name{i}: Value{i}".encode() for i in range(max_headers - 1) |
| 411 | ) |
| 412 | body = ( |
| 413 | b"HTTP/1.1 200 OK\r\n" |
| 414 | + b"\r\n".join(headers) |
| 415 | + b"\r\nContent-Length: 12\r\n\r\nDummy body\r\n" |
| 416 | ) |
| 417 | |
| 418 | with self.subTest(max_headers=None): |
| 419 | conn = client.HTTPConnection("example.com") |
| 420 | conn.sock = FakeSocket(body) |
| 421 | conn.request("GET", "/") |
| 422 | with self.assertRaisesRegex( |
| 423 | client.HTTPException, f"got more than {client._MAXHEADERS} headers" |
| 424 | ): |
| 425 | response = conn.getresponse() |
| 426 | |
| 427 | with self.subTest(max_headers=None): |
| 428 | conn = client.HTTPConnection( |
| 429 | "example.com", max_response_headers=max_headers |
| 430 | ) |
| 431 | conn.sock = FakeSocket(body) |
| 432 | conn.request("GET", "/") |
| 433 | response = conn.getresponse() |
| 434 | response.read() |
| 435 | |
| 436 | class HttpMethodTests(TestCase): |
| 437 | def test_invalid_method_names(self): |
nothing calls this directly
no test coverage detected