MCPcopy Index your code
hub / github.com/python/cpython / proxy_bypass_environment

Function proxy_bypass_environment

Lib/urllib/request.py:1911–1943  ·  view source on GitHub ↗

Test if proxies should not be used for a particular host. Checks the proxy dict for the value of no_proxy, which should be a list of comma separated DNS suffixes, or '*' for all hosts.

(host, proxies=None)

Source from the content-addressed store, hash-verified

1909 return proxies
1910
1911def proxy_bypass_environment(host, proxies=None):
1912 """Test if proxies should not be used for a particular host.
1913
1914 Checks the proxy dict for the value of no_proxy, which should
1915 be a list of comma separated DNS suffixes, or '*' for all hosts.
1916
1917 """
1918 if proxies is None:
1919 proxies = getproxies_environment()
1920 # don't bypass, if no_proxy isn't specified
1921 try:
1922 no_proxy = proxies['no']
1923 except KeyError:
1924 return False
1925 # '*' is special case for always bypass
1926 if no_proxy == '*':
1927 return True
1928 host = host.lower()
1929 # strip port off host
1930 hostonly, port = _splitport(host)
1931 # check if the host ends with any of the DNS suffixes
1932 for name in no_proxy.split(','):
1933 name = name.strip()
1934 if name:
1935 name = name.lstrip('.') # ignore leading dots
1936 name = name.lower()
1937 if hostonly == name or host == name:
1938 return True
1939 name = '.' + name
1940 if hostonly.endswith(name) or host.endswith(name):
1941 return True
1942 # otherwise, don't bypass
1943 return False
1944
1945
1946# This code tests an OSX specific data structure but is testable on all

Callers 1

proxy_bypassFunction · 0.85

Calls 7

_splitportFunction · 0.90
getproxies_environmentFunction · 0.85
lowerMethod · 0.45
splitMethod · 0.45
stripMethod · 0.45
lstripMethod · 0.45
endswithMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…