Exemplo n.º 1
0
    def make_connection(self, host):
        if self._connection and host == self._connection[0]:
            return self._connection[1]

        if not hasattr(http_client, "HTTPSConnection"):
            raise NotImplementedError(
                "your version of http.client doesn't support HTTPS")
        # create a HTTPS connection object from a host descriptor
        # host may be a string, or a (host, x509-dict) tuple
        chost, self._extra_headers, x509 = self.get_host_info(host)
        self._connection = host, http_client.HTTPSConnection(
            chost, None, **(x509 or {}))
        return self._connection[1]
Exemplo n.º 2
0
    def test_host_port(self):
        # Check invalid host_port

        # Note that httplib does not accept user:password@ in the host-port.
        for hp in ("www.python.org:abc", "user:[email protected]"):
            self.assertRaises(client.InvalidURL, client.HTTPSConnection, hp)

        for hp, h, p in (("[fe80::207:e9ff:fe9b]:8000", "fe80::207:e9ff:fe9b",
                          8000),
                         ("pypi.python.org:443", "pypi.python.org", 443),
                         ("pypi.python.org", "pypi.python.org", 443),
                         ("pypi.python.org:", "pypi.python.org", 443),
                         ("[fe80::207:e9ff:fe9b]", "fe80::207:e9ff:fe9b", 443)):
            c = client.HTTPSConnection(hp)
            self.assertEqual(h, c.host)
            self.assertEqual(p, c.port)
Exemplo n.º 3
0
 def test_attributes(self):
     # simple test to check it's storing it
     if hasattr(client, 'HTTPSConnection'):
         h = client.HTTPSConnection(HOST, TimeoutTest.PORT, timeout=30)
         self.assertEqual(h.timeout, 30)
Exemplo n.º 4
0
 def testHTTPSConnectionSourceAddress(self):
     self.conn = client.HTTPSConnection(HOST, self.port,
             source_address=('', self.source_port))