[Yum-devel] [PATCH] New ftp/http/https proxy setting code. May fix BZ 769254.

Zdeněk Pavlas zpavlas at redhat.com
Thu Feb 16 08:32:43 UTC 2012


- FTP proxies might actually start to work.
- HTTP and HTTPS request now prefer the 'right' proxy,
  instead of relying on random dictionary ordering.
- PROXYAUTH set to HTTPAUTH_ANY, allowing NTLM auth.

Potentia
---
 urlgrabber/grabber.py |   24 ++++++++++--------------
 1 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/urlgrabber/grabber.py b/urlgrabber/grabber.py
index d5ce06b..2128bc6 100644
--- a/urlgrabber/grabber.py
+++ b/urlgrabber/grabber.py
@@ -1331,20 +1331,16 @@ class PyCurlFileObject(object):
             self.curl_obj.setopt(pycurl.MAX_RECV_SPEED_LARGE, int(opts.raw_throttle()))
             
         # proxy settings
-        if opts.proxies:
-            for (scheme, proxy) in opts.proxies.items():
-                if self.scheme in ('ftp'): # only set the ftp proxy for ftp items
-                    if scheme not in ('ftp'):
-                        continue
-                    else:
-                        if proxy == '_none_': proxy = ""
-                        self.curl_obj.setopt(pycurl.PROXY, proxy)
-                elif self.scheme in ('http', 'https'):
-                    if scheme not in ('http', 'https'):
-                        continue
-                    else:
-                        if proxy == '_none_': proxy = ""
-                        self.curl_obj.setopt(pycurl.PROXY, proxy)
+        if opts.proxies and self.scheme in ('ftp', 'http', 'https'):
+            proxy = opts.proxies.get(self.scheme)
+            if proxy is None:
+                if self.scheme == 'http':
+                    proxy = opts.proxies.get('https')
+                elif self.scheme == 'https':
+                    proxy = opts.proxies.get('http')
+            if proxy and proxy != '_none_':
+                self.curl_obj.setopt(pycurl.PROXY, proxy)
+                self.curl_obj.setopt(pycurl.PROXYAUTH, pycurl.HTTPAUTH_ANY)
             
         if opts.username and opts.password:
             if self.scheme in ('http', 'https'):
-- 
1.7.4.4



More information about the Yum-devel mailing list