diff options
author | Georg Brandl <georg@python.org> | 2014-09-30 14:08:04 +0200 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2014-09-30 14:08:04 +0200 |
commit | f0746ca46376647993a47e24051a80fdf679014a (patch) | |
tree | 55faff27b29f3afe16e29c56f382f1572b7e791f /Lib/test | |
parent | ec3c103520a5061e657581b388e2b8ba6f74602a (diff) | |
download | cpython-git-f0746ca46376647993a47e24051a80fdf679014a.tar.gz |
Issue #16037: HTTPMessage.readheaders() raises an HTTPException when more than
100 headers are read. Adapted from patch by Jyrki Pulliainen.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_httplib.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py index 420302c332..226e79ecca 100644 --- a/Lib/test/test_httplib.py +++ b/Lib/test/test_httplib.py @@ -272,6 +272,15 @@ class BasicTest(TestCase): if resp.read(): self.fail("Did not expect response from HEAD request") + def test_too_many_headers(self): + headers = '\r\n'.join('Header%d: foo' % i + for i in range(client._MAXHEADERS + 1)) + '\r\n' + text = ('HTTP/1.1 200 OK\r\n' + headers) + s = FakeSocket(text) + r = client.HTTPResponse(s) + self.assertRaisesRegex(client.HTTPException, + r"got more than \d+ headers", r.begin) + def test_send_file(self): expected = (b'GET /foo HTTP/1.1\r\nHost: example.com\r\n' b'Accept-Encoding: identity\r\nContent-Length:') |