Python urllib.getproxies_environment() Examples
The following are 14
code examples of urllib.getproxies_environment().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
urllib
, or try the search function
.
Example #1
Source File: test_urllib.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_getproxies_environment_prefer_lowercase(self): # Test lowercase preference with removal os.environ['no_proxy'] = '' os.environ['No_Proxy'] = 'localhost' self.assertFalse(urllib.proxy_bypass_environment('localhost')) self.assertFalse(urllib.proxy_bypass_environment('arbitrary')) os.environ['http_proxy'] = '' os.environ['HTTP_PROXY'] = 'http://somewhere:3128' proxies = urllib.getproxies_environment() self.assertEqual({}, proxies) # Test lowercase preference of proxy bypass and correct matching including ports os.environ['no_proxy'] = 'localhost, noproxy.com, my.proxy:1234' os.environ['No_Proxy'] = 'xyz.com' self.assertTrue(urllib.proxy_bypass_environment('localhost')) self.assertTrue(urllib.proxy_bypass_environment('noproxy.com:5678')) self.assertTrue(urllib.proxy_bypass_environment('my.proxy:1234')) self.assertFalse(urllib.proxy_bypass_environment('my.proxy')) self.assertFalse(urllib.proxy_bypass_environment('arbitrary')) # Test lowercase preference with replacement os.environ['http_proxy'] = 'http://somewhere:3128' os.environ['Http_Proxy'] = 'http://somewhereelse:3128' proxies = urllib.getproxies_environment() self.assertEqual('http://somewhere:3128', proxies['http'])
Example #2
Source File: test_urllib.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def test_getproxies_environment_prefer_lowercase(self): # Test lowercase preference with removal os.environ['no_proxy'] = '' os.environ['No_Proxy'] = 'localhost' self.assertFalse(urllib.proxy_bypass_environment('localhost')) self.assertFalse(urllib.proxy_bypass_environment('arbitrary')) os.environ['http_proxy'] = '' os.environ['HTTP_PROXY'] = 'http://somewhere:3128' proxies = urllib.getproxies_environment() self.assertEqual({}, proxies) # Test lowercase preference of proxy bypass and correct matching including ports os.environ['no_proxy'] = 'localhost, noproxy.com, my.proxy:1234' os.environ['No_Proxy'] = 'xyz.com' self.assertTrue(urllib.proxy_bypass_environment('localhost')) self.assertTrue(urllib.proxy_bypass_environment('noproxy.com:5678')) self.assertTrue(urllib.proxy_bypass_environment('my.proxy:1234')) self.assertFalse(urllib.proxy_bypass_environment('my.proxy')) self.assertFalse(urllib.proxy_bypass_environment('arbitrary')) # Test lowercase preference with replacement os.environ['http_proxy'] = 'http://somewhere:3128' os.environ['Http_Proxy'] = 'http://somewhereelse:3128' proxies = urllib.getproxies_environment() self.assertEqual('http://somewhere:3128', proxies['http'])
Example #3
Source File: test_urllib.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
def test_getproxies_environment_prefer_lowercase(self): # Test lowercase preference with removal os.environ['no_proxy'] = '' os.environ['No_Proxy'] = 'localhost' self.assertFalse(urllib.proxy_bypass_environment('localhost')) self.assertFalse(urllib.proxy_bypass_environment('arbitrary')) os.environ['http_proxy'] = '' os.environ['HTTP_PROXY'] = 'http://somewhere:3128' proxies = urllib.getproxies_environment() self.assertEqual({}, proxies) # Test lowercase preference of proxy bypass and correct matching including ports os.environ['no_proxy'] = 'localhost, noproxy.com, my.proxy:1234' os.environ['No_Proxy'] = 'xyz.com' self.assertTrue(urllib.proxy_bypass_environment('localhost')) self.assertTrue(urllib.proxy_bypass_environment('noproxy.com:5678')) self.assertTrue(urllib.proxy_bypass_environment('my.proxy:1234')) self.assertFalse(urllib.proxy_bypass_environment('my.proxy')) self.assertFalse(urllib.proxy_bypass_environment('arbitrary')) # Test lowercase preference with replacement os.environ['http_proxy'] = 'http://somewhere:3128' os.environ['Http_Proxy'] = 'http://somewhereelse:3128' proxies = urllib.getproxies_environment() self.assertEqual('http://somewhere:3128', proxies['http'])
Example #4
Source File: test_urllib.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_getproxies_environment_keep_no_proxies(self): self.env.set('NO_PROXY', 'localhost') proxies = urllib.getproxies_environment() # getproxies_environment use lowered case truncated (no '_proxy') keys self.assertEqual('localhost', proxies['no']) # List of no_proxies with space. self.env.set('NO_PROXY', 'localhost, anotherdomain.com, newdomain.com:1234') self.assertTrue(urllib.proxy_bypass_environment('anotherdomain.com')) self.assertTrue(urllib.proxy_bypass_environment('anotherdomain.com:8888')) self.assertTrue(urllib.proxy_bypass_environment('newdomain.com:1234'))
Example #5
Source File: test_urllib.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_proxy_cgi_ignore(self): try: self.env.set('HTTP_PROXY', 'http://somewhere:3128') proxies = urllib.getproxies_environment() self.assertEqual('http://somewhere:3128', proxies['http']) self.env.set('REQUEST_METHOD', 'GET') proxies = urllib.getproxies_environment() self.assertNotIn('http', proxies) finally: self.env.unset('REQUEST_METHOD') self.env.unset('HTTP_PROXY')
Example #6
Source File: base.py From tornado-botocore with MIT License | 5 votes |
def __init__(self, service, operation, region_name, endpoint_url=None, session=None, connect_timeout=None, request_timeout=None): # set credentials manually session = session or botocore.session.get_session() # get_session accepts access_key, secret_key self.client = session.create_client( service, region_name=region_name, endpoint_url=endpoint_url ) try: self.endpoint = self.client.endpoint except AttributeError: self.endpoint = self.client._endpoint self.operation = operation self.http_client = AsyncHTTPClient() self.proxy_host = None self.proxy_port = None https_proxy = getproxies_environment().get('https') if https_proxy: self._enable_curl_httpclient() proxy_parts = https_proxy.split(':') if len(proxy_parts) == 2 and proxy_parts[-1].isdigit(): self.proxy_host, self.proxy_port = proxy_parts self.proxy_port = int(self.proxy_port) else: proxy = urlparse(https_proxy) self.proxy_host = proxy.hostname self.proxy_port = proxy.port self.request_timeout = request_timeout self.connect_timeout = connect_timeout
Example #7
Source File: test_urllib.py From BinderFilter with MIT License | 5 votes |
def test_getproxies_environment_keep_no_proxies(self): self.env.set('NO_PROXY', 'localhost') proxies = urllib.getproxies_environment() # getproxies_environment use lowered case truncated (no '_proxy') keys self.assertEqual('localhost', proxies['no']) # List of no_proxies with space. self.env.set('NO_PROXY', 'localhost, anotherdomain.com, newdomain.com') self.assertTrue(urllib.proxy_bypass_environment('anotherdomain.com'))
Example #8
Source File: test_urllib.py From oss-ftp with MIT License | 5 votes |
def test_getproxies_environment_keep_no_proxies(self): self.env.set('NO_PROXY', 'localhost') proxies = urllib.getproxies_environment() # getproxies_environment use lowered case truncated (no '_proxy') keys self.assertEqual('localhost', proxies['no']) # List of no_proxies with space. self.env.set('NO_PROXY', 'localhost, anotherdomain.com, newdomain.com') self.assertTrue(urllib.proxy_bypass_environment('anotherdomain.com'))
Example #9
Source File: test_urllib.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_getproxies_environment_keep_no_proxies(self): self.env.set('NO_PROXY', 'localhost') proxies = urllib.getproxies_environment() # getproxies_environment use lowered case truncated (no '_proxy') keys self.assertEqual('localhost', proxies['no']) # List of no_proxies with space. self.env.set('NO_PROXY', 'localhost, anotherdomain.com, newdomain.com') self.assertTrue(urllib.proxy_bypass_environment('anotherdomain.com'))
Example #10
Source File: ovirt_proxied_check.py From ovirt-ansible-hosted-engine-setup with Apache License 2.0 | 5 votes |
def proxied(value): netloc = urlparse(value).netloc proxied = bool(getproxies_environment()) and not proxy_bypass(netloc) return(proxied)
Example #11
Source File: test_urllib.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_getproxies_environment_keep_no_proxies(self): self.env.set('NO_PROXY', 'localhost') proxies = urllib.getproxies_environment() # getproxies_environment use lowered case truncated (no '_proxy') keys self.assertEqual('localhost', proxies['no']) # List of no_proxies with space. self.env.set('NO_PROXY', 'localhost, anotherdomain.com, newdomain.com:1234') self.assertTrue(urllib.proxy_bypass_environment('anotherdomain.com')) self.assertTrue(urllib.proxy_bypass_environment('anotherdomain.com:8888')) self.assertTrue(urllib.proxy_bypass_environment('newdomain.com:1234'))
Example #12
Source File: test_urllib.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_proxy_cgi_ignore(self): try: self.env.set('HTTP_PROXY', 'http://somewhere:3128') proxies = urllib.getproxies_environment() self.assertEqual('http://somewhere:3128', proxies['http']) self.env.set('REQUEST_METHOD', 'GET') proxies = urllib.getproxies_environment() self.assertNotIn('http', proxies) finally: self.env.unset('REQUEST_METHOD') self.env.unset('HTTP_PROXY')
Example #13
Source File: test_urllib.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_getproxies_environment_keep_no_proxies(self): self.env.set('NO_PROXY', 'localhost') proxies = urllib.getproxies_environment() # getproxies_environment use lowered case truncated (no '_proxy') keys self.assertEqual('localhost', proxies['no']) # List of no_proxies with space. self.env.set('NO_PROXY', 'localhost, anotherdomain.com, newdomain.com:1234') self.assertTrue(urllib.proxy_bypass_environment('anotherdomain.com')) self.assertTrue(urllib.proxy_bypass_environment('anotherdomain.com:8888')) self.assertTrue(urllib.proxy_bypass_environment('newdomain.com:1234'))
Example #14
Source File: test_urllib.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_proxy_cgi_ignore(self): try: self.env.set('HTTP_PROXY', 'http://somewhere:3128') proxies = urllib.getproxies_environment() self.assertEqual('http://somewhere:3128', proxies['http']) self.env.set('REQUEST_METHOD', 'GET') proxies = urllib.getproxies_environment() self.assertNotIn('http', proxies) finally: self.env.unset('REQUEST_METHOD') self.env.unset('HTTP_PROXY')