Skip to content
Myr

Merge pull request #581 from crodjer/develop

Before adoption: this commit came in with the history the project adopted, so no landing records it.

A utility for using environment proxies

authored by Kenneth Reitz · committed by Kenneth Reitz · parents 8bd6515, 7cf6ca8 · Browse files · 3 files+19 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+19 added−5 removed

  • other:+19 added−5 removed

3 files+19 added−5 removed

modified:requests/models.py+2 added-5 removed
26 unmodified lines
27 ConnectionError, HTTPError, RequestException, Timeout, TooManyRedirects,28 URLRequired, SSLError, MissingSchema, InvalidSchema, InvalidURL)29from .utils import (30 get_encoding_from_headers, stream_untransfer, guess_filename, requote_uri,31 stream_decode_response_unicode, get_netrc_auth,31 stream_decode_response_unicode, get_netrc_auth, get_environ_proxies,32 DEFAULT_CA_BUNDLE_PATH)33from .compat import (34 cookielib, urlparse, urlunparse, urljoin, urlsplit, urlencode, str, bytes,35 is_py2)
75 unmodified lines
111112 # If no proxies are given, allow configuration by environment variables113 # HTTP_PROXY and HTTPS_PROXY.114 if not self.proxies and self.config.get('trust_env'):115 if 'HTTP_PROXY' in os.environ:116 self.proxies['http'] = os.environ['HTTP_PROXY']117 if 'HTTPS_PROXY' in os.environ:118 self.proxies['https'] = os.environ['HTTPS_PROXY']115 self.proxies = get_environ_proxies()116117 self.data = data118 self.params = params119 self.files = files
714 unmodified lines
modified:requests/utils.py+16 added
444 unmodified lines
445 # Unquote only the unreserved characters446 # Then quote only illegal characters (do not quote reserved, unreserved,447 # or '%')448 return quote(unquote_unreserved(uri), safe="!#$%&'()*+,/:;=?@[]~")449450def get_environ_proxies():451 """Return a dict of environment proxies."""452453 proxy_keys = [454 'all',455 'http',456 'https',457 'ftp',458 'socks',459 'no'460 ]461462 get_proxy = lambda k: os.environ.get(k) or os.environ.get(k.upper())463 proxies = [(key, get_proxy(key + '_proxy')) for key in proxy_keys]464 return dict([(key, val) for (key, val) in proxies if val])
modified:AUTHORS.rst+1 added
95 unmodified lines
96- Michael Newman <newmaniese@gmail.com>97- Jonty Wareing <jonty@jonty.co.uk>98- Shivaram Lingamneni99- Miguel Turner100- Rohan Jain (crodjer)