(self)
| 1506 | |
| 1507 | @unittest.skipUnless(hasattr(http.client, 'HTTPSConnection'), 'HTTPSConnection required for HTTPS tests.') |
| 1508 | def test_proxy_https_proxy_authorization(self): |
| 1509 | o = OpenerDirector() |
| 1510 | ph = urllib.request.ProxyHandler(dict(https='proxy.example.com:3128')) |
| 1511 | o.add_handler(ph) |
| 1512 | https_handler = MockHTTPSHandler() |
| 1513 | o.add_handler(https_handler) |
| 1514 | req = Request("https://www.example.com/") |
| 1515 | req.add_header("Proxy-Authorization", "FooBar") |
| 1516 | req.add_header("User-Agent", "Grail") |
| 1517 | self.assertEqual(req.host, "www.example.com") |
| 1518 | self.assertIsNone(req._tunnel_host) |
| 1519 | o.open(req) |
| 1520 | # Verify Proxy-Authorization gets tunneled to request. |
| 1521 | # httpsconn req_headers do not have the Proxy-Authorization header but |
| 1522 | # the req will have. |
| 1523 | self.assertNotIn(("Proxy-Authorization", "FooBar"), |
| 1524 | https_handler.httpconn.req_headers) |
| 1525 | self.assertIn(("User-Agent", "Grail"), |
| 1526 | https_handler.httpconn.req_headers) |
| 1527 | self.assertIsNotNone(req._tunnel_host) |
| 1528 | self.assertEqual(req.host, "proxy.example.com:3128") |
| 1529 | self.assertEqual(req.get_header("Proxy-authorization"), "FooBar") |
| 1530 | |
| 1531 | @unittest.skipUnless(os.name == "nt", "only relevant for Windows") |
| 1532 | def test_winreg_proxy_bypass(self): |
nothing calls this directly
no test coverage detected