Downloader.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:enigma2 作者: OpenLD 项目源码 文件源码
def __init__(self, url, outputfile, contextFactory=None, *args, **kwargs):
        if hasattr(client, '_parse'):
            scheme, host, port, path = client._parse(url)
        else:
            try:
                from twisted.web.client import _URI as URI
            except ImportError:
                from twisted.web.client import URI
            uri = URI.fromBytes(url)
            scheme = uri.scheme
            host = uri.host
            port = uri.port or (443 if scheme == 'https' else 80)
            path = uri.path

        self.factory = HTTPProgressDownloader(url, outputfile, *args, **kwargs)
        if scheme == "https":
            from twisted.internet import ssl
            if contextFactory is None:
                contextFactory = ssl.ClientContextFactory()
            self.connection = reactor.connectSSL(host, port, self.factory, contextFactory)
        else:
            self.connection = reactor.connectTCP(host, port, self.factory)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号