http, https ve ftp için proxy desteği (#863)

This commit is contained in:
A. Murat Eren
2006-02-06 12:59:05 +00:00
parent 4726ea8129
commit 3efd20dbce
2 changed files with 22 additions and 0 deletions
+3
View File
@@ -59,6 +59,9 @@ class GeneralDefaults:
autoclean = False autoclean = False
distribution = "Pardus" distribution = "Pardus"
distribution_release = "0.1" distribution_release = "0.1"
http_proxy = os.getenv("HTTP_PROXY") or None
https_proxy = os.getenv("HTTPS_PROXY") or None
ftp_proxy = os.getenv("FTP_PROXY") or None
class BuildDefaults: class BuildDefaults:
"""Default values for [build] section""" """Default values for [build] section"""
+19
View File
@@ -211,6 +211,25 @@ class Fetcher:
urllib2.install_opener(opener) urllib2.install_opener(opener)
request.add_header('Range', 'bytes=%d-' % self.exist_size) request.add_header('Range', 'bytes=%d-' % self.exist_size)
proxy_handler = None
if ctx.config.values.general.http_proxy and self.url.scheme() == "http":
http_proxy = ctx.config.values.general.http_proxy
proxy_handler = urllib2.ProxyHandler({URI(http_proxy).scheme(): http_proxy})
elif ctx.config.values.general.https_proxy and self.url.scheme() == "https":
https_proxy = ctx.config.values.general.https_proxy
proxy_handler = urllib2.ProxyHandler({URI(https_proxy): https_proxy})
elif ctx.config.values.general.ftp_proxy and self.url.scheme() == "ftp":
ftp_proxy = ctx.config.values.general.ftp_proxy
proxy_handler = urllib2.ProxyHandler({URI(http_proxy): ftp_proxy})
if proxy_handler:
ctx.ui.info(_("Proxy configuration has been found for '%s' protocol") % self.url.scheme())
opener = urllib2.build_opener(proxy_handler)
urllib2.install_opener(opener)
return request return request
def err (self, error): def err (self, error):