This adds support for lowercase environment proxy variables (which are
quite popular too). It returns proxies in a format compatible with
request's proxy parameter.
Moreover, it can be used in the request models for proxy defaults.
Signed-off-by: Rohan Jain <crodjer@gmail.com>
# Then quote only illegal characters (do not quote reserved, unreserved,
# or '%')
return quote(unquote_unreserved(uri), safe="!#$%&'()*+,/:;=?@[]~")
+
+def get_environ_proxies():
+ """Return a dict of environment proxies."""
+
+ proxy_keys = [
+ 'all',
+ 'http',
+ 'https',
+ 'ftp',
+ 'socks',
+ 'no'
+ ]
+
+ get_proxy = lambda k: os.environ.get(k) or os.environ.get(k.upper())
+ proxies = [(key, get_proxy(key + '_proxy')) for key in proxy_keys]
+ return dict([(key, val) for (key, val) in proxies if val])