コード例 #1
0
    def __init__(self,
                 host='127.0.0.1',
                 port=8500,
                 scheme='http',
                 verify=True,
                 cert=None,
                 contextFactory=None,
                 **kwargs):
        self.host = host
        self.port = port
        self.scheme = scheme
        self.base_uri = '%s://%s:%s' % (self.scheme, self.host, self.port)

        agent_kwargs = dict(reactor=reactor,
                            pool=HTTPConnectionPool(reactor),
                            **kwargs)
        if contextFactory is not None:
            # use the provided context factory
            agent_kwargs['contextFactory'] = contextFactory
        elif not verify:
            # if no context is provided and verify is set to false, use the
            # insecure context factory implementation
            agent_kwargs['contextFactory'] = InsecureContextFactory()

        self.client = TreqHTTPClient(Agent(**agent_kwargs))
コード例 #2
0
ファイル: twisted.py プロジェクト: mougams/python-consul
    def __init__(self, contextFactory, *args, **kwargs):
        super(HTTPClient, self).__init__(*args, **kwargs)
        agent_kwargs = dict(reactor=reactor, pool=HTTPConnectionPool(reactor))
        if contextFactory is not None:
            # use the provided context factory
            agent_kwargs['contextFactory'] = contextFactory
        elif not self.verify:
            # if no context is provided and verify is set to false, use the
            # insecure context factory implementation
            agent_kwargs['contextFactory'] = InsecureContextFactory()

        self.client = TreqHTTPClient(Agent(**agent_kwargs))
コード例 #3
0
ファイル: twisted.py プロジェクト: joshainglis/python-consul
 def __init__(self, host='127.0.0.1', port=8500, scheme='http',
              verify=True):
     self.host = host
     self.port = port
     self.scheme = scheme
     self.base_uri = '%s://%s:%s' % (self.scheme, self.host, self.port)
     self.verify = SSLSpec.CERT_NONE \
         if not verify else SSLSpec.CERT_REQUIRED
     agent = Agent(reactor=reactor, pool=HTTPConnectionPool(reactor),
                   contextFactory=AsyncClientSSLContextFactory(
                       verify=self.verify))
     self.client = TreqHTTPClient(agent)