diff options
author | Georg Brandl <georg@python.org> | 2013-10-27 06:34:48 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2013-10-27 06:34:48 (GMT) |
commit | bf3f8eb9602154c9434cd82e61d1b103c30615f0 (patch) | |
tree | d5df932a151efb3f0fbe49de78cbc96956dcd91e /Lib/test/test_httplib.py | |
parent | 28e78414f9175774f26d8c564c7c1d3b078f99de (diff) | |
download | cpython-bf3f8eb9602154c9434cd82e61d1b103c30615f0.zip cpython-bf3f8eb9602154c9434cd82e61d1b103c30615f0.tar.gz cpython-bf3f8eb9602154c9434cd82e61d1b103c30615f0.tar.bz2 |
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/test_httplib.py')
-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 769ab13..f3c27c2 100644 --- a/Lib/test/test_httplib.py +++ b/Lib/test/test_httplib.py @@ -345,6 +345,15 @@ class BasicTest(TestCase): self.fail("Did not expect response from HEAD request") self.assertEqual(bytes(b), b'\x00'*5) + 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:') |