@@ -161,14 +161,16 @@ def test_partial_reads(self):
161161 def test_host_port (self ):
162162 # Check invalid host_port
163163
164- for hp in ("www.python.org:abc" , "www.python.org: " ):
164+ for hp in ("www.python.org:abc" , "user:password@ www.python.org" ):
165165 self .assertRaises (client .InvalidURL , client .HTTPConnection , hp )
166166
167167 for hp , h , p in (("[fe80::207:e9ff:fe9b]:8000" ,
168168 "fe80::207:e9ff:fe9b" , 8000 ),
169169 ("www.python.org:80" , "www.python.org" , 80 ),
170+ ("www.python.org:" , "www.python.org" , 80 ),
170171 ("www.python.org" , "www.python.org" , 80 ),
171- ("[fe80::207:e9ff:fe9b]" , "fe80::207:e9ff:fe9b" , 80 )):
172+ ("[fe80::207:e9ff:fe9b]" , "fe80::207:e9ff:fe9b" , 80 ),
173+ ("[fe80::207:e9ff:fe9b]:" , "fe80::207:e9ff:fe9b" , 80 )):
172174 c = client .HTTPConnection (hp )
173175 self .assertEqual (h , c .host )
174176 self .assertEqual (p , c .port )
@@ -539,6 +541,24 @@ def test_local_bad_hostname(self):
539541 self .assertEqual (resp .status , 404 )
540542 del server
541543
544+ def test_host_port (self ):
545+ # Check invalid host_port
546+
547+ for hp in (
"www.python.org:abc" ,
"user:[email protected] " ):
548+ self .assertRaises (client .InvalidURL , client .HTTPSConnection , hp )
549+
550+ for hp , h , p in (("[fe80::207:e9ff:fe9b]:8000" ,
551+ "fe80::207:e9ff:fe9b" , 8000 ),
552+ ("www.python.org:443" , "www.python.org" , 443 ),
553+ ("www.python.org:" , "www.python.org" , 443 ),
554+ ("www.python.org" , "www.python.org" , 443 ),
555+ ("[fe80::207:e9ff:fe9b]" , "fe80::207:e9ff:fe9b" , 443 ),
556+ ("[fe80::207:e9ff:fe9b]:" , "fe80::207:e9ff:fe9b" ,
557+ 443 )):
558+ c = client .HTTPSConnection (hp )
559+ self .assertEqual (h , c .host )
560+ self .assertEqual (p , c .port )
561+
542562
543563class RequestBodyTest (TestCase ):
544564 """Test cases where a request includes a message body."""
0 commit comments