- Improved handling of win32 proxy settings (addresses bug #114256).

The earlier code assumed "protocol=host;protocol=host;..." or "host",
but Windows may also use "protocol=host" (just one entry), as well as
"protocol://host".  This code needs some more work, so I'll leave the
bug open for now.
This commit is contained in:
Fredrik Lundh 2000-09-24 18:51:25 +00:00
parent ab64787dca
commit b49f88bfc1
1 changed files with 27 additions and 22 deletions

View File

@ -1144,18 +1144,23 @@ elif os.name == 'nt':
return proxies
try:
internetSettings = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER,
'Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings')
r'Software\Microsoft\Windows\CurrentVersion\Internet Settings')
proxyEnable = _winreg.QueryValueEx(internetSettings,
'ProxyEnable')[0]
if proxyEnable:
# Returned as Unicode but problems if not converted to ASCII
proxyServer = str(_winreg.QueryValueEx(internetSettings,
'ProxyServer')[0])
if ';' in proxyServer: # Per-protocol settings
if '=' in proxyServer:
# Per-protocol settings
for p in proxyServer.split(';'):
protocol, address = p.split('=')
protocol, address = p.split('=', 1)
proxies[protocol] = '%s://%s' % (protocol, address)
else: # Use one setting for all protocols
else:
# Use one setting for all protocols
if proxyServer[:5] == 'http:':
proxies['http'] = proxyServer
else:
proxies['http'] = 'http://%s' % proxyServer
proxies['ftp'] = 'ftp://%s' % proxyServer
internetSettings.Close()