Пример #1
0
    def make_connection(self, host):
        """Make a connection to `host`. Reuse keepalive connections."""
        # return an existing connection if possible.  This allows
        # HTTP/1.1 keep-alive.
        if self._connection and host == self._connection[0]:
            http = self._connection[1]
        else:
            # create a HTTPS connection object from a host descriptor
            chost, extra_headers, x509 = self.get_host_info(host)

            http = HTTPTLSConnection(chost,
                                     None,
                                     username=self.username,
                                     password=self.password,
                                     certChain=self.certChain,
                                     privateKey=self.privateKey,
                                     checker=self.checker,
                                     settings=self.settings,
                                     ignoreAbruptClose=self.ignoreAbruptClose)
            # store the host argument along with the connection object
            self._connection = host, http
        if not self.conn_class_is_http:
            return http
        http2 = httplib.HTTP()
        http2._setup(http)
        return http2
Пример #2
0
 def make_connection(self, host):
     # create a HTTPS connection object from a host descriptor
     host, extra_headers, x509 = self.get_host_info(host)
     http = HTTPTLSConnection(host, None, self.username, self.password,
                              self.sharedKey, self.certChain,
                              self.privateKey, self.checker.cryptoID,
                              self.checker.protocol,
                              self.checker.x509Fingerprint,
                              self.checker.x509TrustList,
                              self.checker.x509CommonName, self.settings)
     http2 = httplib.HTTP()
     http2._setup(http)
     return http2