diff options
author | Senthil Kumaran <orsenthil@gmail.com> | 2010-09-27 01:40:59 +0000 |
---|---|---|
committer | Senthil Kumaran <orsenthil@gmail.com> | 2010-09-27 01:40:59 +0000 |
commit | 176c73df0fea08a2472f7b617764d74287b57f98 (patch) | |
tree | 4170a609bfbcf27164d7af05af86ead622b84900 /Lib/test/test_urllib2net.py | |
parent | 658f629c86ed1b792f62834a996915c03ba2ba58 (diff) | |
download | cpython-git-176c73df0fea08a2472f7b617764d74287b57f98.tar.gz |
Merged revisions 85025 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r85025 | senthil.kumaran | 2010-09-27 06:56:03 +0530 (Mon, 27 Sep 2010) | 6 lines
Fix Issue1595365 - Adding the req.headers after the un-redirect headers have
been added. This helps in accidental overwritting of User-Agent header to
default value. To preserve the old behavior, only headers not in unredirected
headers will be updated.
........
Diffstat (limited to 'Lib/test/test_urllib2net.py')
-rw-r--r-- | Lib/test/test_urllib2net.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_urllib2net.py b/Lib/test/test_urllib2net.py index 56e952d147..5ace162e7b 100644 --- a/Lib/test/test_urllib2net.py +++ b/Lib/test/test_urllib2net.py @@ -172,6 +172,18 @@ class OtherNetworkTests(unittest.TestCase): finally: res.close() + def test_custom_headers(self): + url = "http://www.example.com" + opener = urllib2.build_opener() + request = urllib2.Request(url) + self.assertFalse(request.header_items()) + opener.open(request) + self.assertTrue(request.header_items()) + self.assertTrue(request.has_header('User-agent')) + request.add_header('User-Agent','Test-Agent') + opener.open(request) + self.assertEqual(request.get_header('User-agent'),'Test-Agent') + def _test_urls(self, urls, handlers, retry=True): import time import logging |