MCPcopy Index your code
hub / github.com/RustPython/RustPython / proxy_bypass_environment

Function proxy_bypass_environment

Lib/urllib/request.py:1909–1941  ·  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

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