[Python-checkins] r75336 - in python/branches/release31-maint: Lib/test/test_urllib2.py Lib/urllib/request.py Misc/NEWS
senthil.kumaran
python-checkins at python.org
Sun Oct 11 08:07:46 CEST 2009
Author: senthil.kumaran
Date: Sun Oct 11 08:07:46 2009
New Revision: 75336
Log:
Merged revisions 75334 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
................
r75334 | senthil.kumaran | 2009-10-11 10:28:55 +0530 (Sun, 11 Oct 2009) | 9 lines
Merged revisions 75333 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r75333 | senthil.kumaran | 2009-10-11 07:30:07 +0530 (Sun, 11 Oct 2009) | 3 lines
Fixed Issue6894, urllib2 doesn't respect "no_proxy" environment
........
................
Modified:
python/branches/release31-maint/ (props changed)
python/branches/release31-maint/Lib/test/test_urllib2.py
python/branches/release31-maint/Lib/urllib/request.py
python/branches/release31-maint/Misc/NEWS
Modified: python/branches/release31-maint/Lib/test/test_urllib2.py
==============================================================================
--- python/branches/release31-maint/Lib/test/test_urllib2.py (original)
+++ python/branches/release31-maint/Lib/test/test_urllib2.py Sun Oct 11 08:07:46 2009
@@ -947,6 +947,22 @@
self.assertEqual([(handlers[0], "http_open")],
[tup[0:2] for tup in o.calls])
+ def test_proxy_no_proxy(self):
+ os.environ['no_proxy'] = 'python.org'
+ o = OpenerDirector()
+ ph = urllib.request.ProxyHandler(dict(http="proxy.example.com"))
+ o.add_handler(ph)
+ req = Request("http://www.perl.org/")
+ self.assertEqual(req.get_host(), "www.perl.org")
+ r = o.open(req)
+ self.assertEqual(req.get_host(), "proxy.example.com")
+ req = Request("http://www.python.org")
+ self.assertEqual(req.get_host(), "www.python.org")
+ r = o.open(req)
+ self.assertEqual(req.get_host(), "www.python.org")
+ del os.environ['no_proxy']
+
+
def test_proxy_https(self):
o = OpenerDirector()
ph = urllib.request.ProxyHandler(dict(https="proxy.example.com:3128"))
Modified: python/branches/release31-maint/Lib/urllib/request.py
==============================================================================
--- python/branches/release31-maint/Lib/urllib/request.py (original)
+++ python/branches/release31-maint/Lib/urllib/request.py Sun Oct 11 08:07:46 2009
@@ -657,6 +657,10 @@
proxy_type, user, password, hostport = _parse_proxy(proxy)
if proxy_type is None:
proxy_type = orig_type
+
+ if req.host and proxy_bypass(req.host):
+ return None
+
if user and password:
user_pass = '%s:%s' % (unquote(user),
unquote(password))
Modified: python/branches/release31-maint/Misc/NEWS
==============================================================================
--- python/branches/release31-maint/Misc/NEWS (original)
+++ python/branches/release31-maint/Misc/NEWS Sun Oct 11 08:07:46 2009
@@ -27,6 +27,8 @@
Library
-------
+- Issue #6894: Fixed the issue urllib2 doesn't respect "no_proxy" environment
+
- Issue #7082: When falling back to the MIME 'name' parameter, the
correct place to look for it is the Content-Type header.
More information about the Python-checkins
mailing list