diff options
author | Łukasz Langa <lukasz@langa.pl> | 2011-10-18 19:17:39 (GMT) |
---|---|---|
committer | Łukasz Langa <lukasz@langa.pl> | 2011-10-18 19:17:39 (GMT) |
commit | a5a9a9c3696af0a4a0df74618e63a4d47a62e00f (patch) | |
tree | 60ac753332086566983891dc30d3caaa04668928 /Lib/test/test_httplib.py | |
parent | 551ba20e8ea9a4a97cf63f28b47175e084eb63cd (diff) | |
download | cpython-a5a9a9c3696af0a4a0df74618e63a4d47a62e00f.zip cpython-a5a9a9c3696af0a4a0df74618e63a4d47a62e00f.tar.gz cpython-a5a9a9c3696af0a4a0df74618e63a4d47a62e00f.tar.bz2 |
Fixes #10860: Handle empty port after port delimiter in httplib
Diffstat (limited to 'Lib/test/test_httplib.py')
-rw-r--r-- | Lib/test/test_httplib.py | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py index 4899ac7..8a328a9 100644 --- a/Lib/test/test_httplib.py +++ b/Lib/test/test_httplib.py @@ -161,14 +161,16 @@ class BasicTest(TestCase): def test_host_port(self): # Check invalid host_port - for hp in ("www.python.org:abc", "www.python.org:"): + for hp in ("www.python.org:abc", "user:password@www.python.org"): self.assertRaises(client.InvalidURL, client.HTTPConnection, hp) for hp, h, p in (("[fe80::207:e9ff:fe9b]:8000", "fe80::207:e9ff:fe9b", 8000), ("www.python.org:80", "www.python.org", 80), + ("www.python.org:", "www.python.org", 80), ("www.python.org", "www.python.org", 80), - ("[fe80::207:e9ff:fe9b]", "fe80::207:e9ff:fe9b", 80)): + ("[fe80::207:e9ff:fe9b]", "fe80::207:e9ff:fe9b", 80), + ("[fe80::207:e9ff:fe9b]:", "fe80::207:e9ff:fe9b", 80)): c = client.HTTPConnection(hp) self.assertEqual(h, c.host) self.assertEqual(p, c.port) @@ -539,6 +541,24 @@ class HTTPSTest(TestCase): resp = h.getresponse() self.assertEqual(resp.status, 404) + def test_host_port(self): + # Check invalid host_port + + for hp in ("www.python.org:abc", "user:password@www.python.org"): + self.assertRaises(client.InvalidURL, client.HTTPSConnection, hp) + + for hp, h, p in (("[fe80::207:e9ff:fe9b]:8000", + "fe80::207:e9ff:fe9b", 8000), + ("www.python.org:443", "www.python.org", 443), + ("www.python.org:", "www.python.org", 443), + ("www.python.org", "www.python.org", 443), + ("[fe80::207:e9ff:fe9b]", "fe80::207:e9ff:fe9b", 443), + ("[fe80::207:e9ff:fe9b]:", "fe80::207:e9ff:fe9b", + 443)): + c = client.HTTPSConnection(hp) + self.assertEqual(h, c.host) + self.assertEqual(p, c.port) + class RequestBodyTest(TestCase): """Test cases where a request includes a message body.""" |