diff options
author | Senthil Kumaran <senthil@uthcode.com> | 2011-07-27 00:05:58 (GMT) |
---|---|---|
committer | Senthil Kumaran <senthil@uthcode.com> | 2011-07-27 00:05:58 (GMT) |
commit | 1299a8f3b25a543c79f79e6edaebb033018029ca (patch) | |
tree | d6654f73c078b2f969892dc917d2dc755e203848 /Lib/test/test_urllib2net.py | |
parent | 5cd3e305e3ef19f6009f3097a7b2ff98b2234bec (diff) | |
download | cpython-1299a8f3b25a543c79f79e6edaebb033018029ca.zip cpython-1299a8f3b25a543c79f79e6edaebb033018029ca.tar.gz cpython-1299a8f3b25a543c79f79e6edaebb033018029ca.tar.bz2 |
Fix closes Issue12576 - fix urlopen behavior on sites which do not send (or obsfuscates) Connection: Close header.
Diffstat (limited to 'Lib/test/test_urllib2net.py')
-rw-r--r-- | Lib/test/test_urllib2net.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_urllib2net.py b/Lib/test/test_urllib2net.py index a475f56..cd225c9 100644 --- a/Lib/test/test_urllib2net.py +++ b/Lib/test/test_urllib2net.py @@ -174,6 +174,22 @@ class OtherNetworkTests(unittest.TestCase): opener.open(request) self.assertEqual(request.get_header('User-agent'),'Test-Agent') + def test_sites_no_connection_close(self): + # Some sites do not send Connection: close header. + # Verify that those work properly. (#issue12576) + + try: + with urllib.request.urlopen('http://www.imdb.com') as res: + pass + except ValueError as e: + self.fail("urlopen failed for sites not sending Connection:close") + else: + self.assertTrue(res) + + req = urllib.request.urlopen('http://www.imdb.com') + res = req.read() + self.assertTrue(res) + def _test_urls(self, urls, handlers, retry=True): import time import logging |