http, https ve ftp için proxy desteği (#863)
This commit is contained in:
@@ -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"""
|
||||||
|
|||||||
@@ -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):
|
||||||
|
|||||||
Reference in New Issue
Block a user