Mercurial > cpython-lru_cache-weakref
diff Lib/test/test_httpservers.py @ 66970:436bbc7f0aa6
Issue #10714: Limit length of incoming request in http.server to 65536 bytes
for security reasons. Initial patch by Ross Lagerwall.
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Thu, 16 Dec 2010 16:48:36 +0000 |
| parents | 9a2058309c1a |
| children | 0b94635ed2f6 |
line wrap: on
line diff
--- a/Lib/test/test_httpservers.py Thu Dec 16 13:33:56 2010 +0000 +++ b/Lib/test/test_httpservers.py Thu Dec 16 16:48:36 2010 +0000 @@ -566,6 +566,12 @@ self.assertEqual(sum(r == b'Connection: close\r\n' for r in result[1:-1]), 1) self.handler = usual_handler # Restore to avoid breaking any subsequent tests. + def test_request_length(self): + # Issue #10714: huge request lines are discarded, to avoid Denial + # of Service attacks. + result = self.send_typical_request(b'GET ' + b'x' * 65537) + self.assertEqual(result[0], b'HTTP/1.1 414 Request-URI Too Long\r\n') + self.assertFalse(self.handler.get_called) class SimpleHTTPRequestHandlerTestCase(unittest.TestCase): """ Test url parsing """
