Esempio n. 1
0
 def get_connection(self, host):
     if self.verbose:
         print("Connecting via https to %s proxy %s, username %s, pass %s" % (
             host, self._proxy, self._proxy_username, self._proxy_password))
     if self.timeout:
         return connections.HTTPSProxyConnection(self._proxy, host,
             username=self._proxy_username, password=self._proxy_password,
             trusted_certs=self.trusted_certs, timeout=self.timeout)
     else:
         return connections.HTTPSProxyConnection(self._proxy, host,
             username=self._proxy_username, password=self._proxy_password,
             trusted_certs=self.trusted_certs)
Esempio n. 2
0
 def get_connection(self):
     if self._scheme not in ['http', 'https']:
         raise ValueError("Unsupported scheme", self._scheme)
     params = {}
     if self._timeout is not None:
         params['timeout'] = self._timeout
     if self._proxy_host:
         params.update({
             'host':
             self._host,
             'port':
             self._port,
             'proxy':
             "%s:%s" % (self._proxy_host, self._proxy_port),
             'username':
             self._proxy_username,
             'password':
             self._proxy_password,
         })
         if self._scheme == 'http':
             return connections.HTTPProxyConnection(**params)
         params['trusted_certs'] = self._trusted_certs
         return connections.HTTPSProxyConnection(**params)
     else:
         if self._scheme == 'http':
             return connections.HTTPConnection(self._host, self._port,
                                               **params)
         params['trusted_certs'] = self._trusted_certs
         return connections.HTTPSConnection(self._host, self._port,
                                            **params)