Dulwich.io dulwich / 4257373
Add support for honoring HTTP proxy environment variables. Thanks, Aurélien Campéas. Fixes #797 Jelmer Vernooij 24 days ago
3 changed file(s) with 26 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
1010
1111 * Fix porcelain.path_to_tree_path for Python 3.5.
1212 (Boris Feld, #777)
13
14 * Add support for honor proxy environment variables for HTTP.
15 (Aurélien Campéas, #797)
1316
1417 0.20.5 2020-06-22
1518
14751475 proxy_server = user_agent = None
14761476 ca_certs = ssl_verify = None
14771477
1478 if proxy_server is None:
1479 for proxyname in ('https_proxy', 'http_proxy', 'all_proxy'):
1480 proxy_server = os.environ.get(proxyname)
1481 if proxy_server is not None:
1482 break
1483
14781484 if config is not None:
1479 try:
1480 proxy_server = config.get(b"http", b"proxy")
1481 except KeyError:
1482 pass
1485 if proxy_server is None:
1486 try:
1487 proxy_server = config.get(b"http", b"proxy")
1488 except KeyError:
1489 pass
14831490 try:
14841491 user_agent = config.get(b"http", b"useragent")
14851492 except KeyError:
11071107 self.assertEqual(manager.proxy.host, 'localhost')
11081108 self.assertEqual(manager.proxy.port, 3128)
11091109
1110 def test_environment_proxy(self):
1111 import urllib3
1112 config = ConfigDict()
1113 os.environ['http_proxy'] = 'http://myproxy:8080'
1114 manager = default_urllib3_manager(config=config)
1115 self.assertIsInstance(manager, urllib3.ProxyManager)
1116 self.assertTrue(hasattr(manager, 'proxy'))
1117 self.assertEqual(manager.proxy.scheme, 'http')
1118 self.assertEqual(manager.proxy.host, 'myproxy')
1119 self.assertEqual(manager.proxy.port, 8080)
1120 del os.environ['http_proxy']
1121
11101122 def test_config_proxy_custom_cls(self):
11111123 import urllib3
11121124