client2.py 文件源码

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

项目:data007 作者: mobishift2011 项目源码 文件源码
def _makeGetterFactory(url, factoryFactory, contextFactory=None,
                       *args, **kwargs):
    """
    Create and connect an HTTP page getting factory.

    Any additional positional or keyword arguments are used when calling
    C{factoryFactory}.

    @param factoryFactory: Factory factory that is called with C{url}, C{args}
        and C{kwargs} to produce the getter

    @param contextFactory: Context factory to use when creating a secure
        connection, defaulting to C{None}

    @return: The factory created by C{factoryFactory}
    """
    scheme, host, port, path = _parse(url)
    factory = factoryFactory(url, *args, **kwargs)
    if scheme == b'https':
        from twisted.internet import ssl
        if contextFactory is None:
            contextFactory = ssl.ClientContextFactory()
        reactor.connectSSL(nativeString(host), port, factory, contextFactory)
    else:
        reactor.connectTCP(nativeString(host), port, factory)
    return factory
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号