Index: dist/src/Doc/lib/liburllib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liburllib.tex,v retrieving revision 1.40 diff -u -w -r1.40 liburllib.tex --- dist/src/Doc/lib/liburllib.tex 20 Oct 2001 04:24:09 -0000 1.40 +++ dist/src/Doc/lib/liburllib.tex 27 Feb 2002 14:38:54 -0000 @@ -18,7 +18,7 @@ It defines the following public functions: -\begin{funcdesc}{urlopen}{url\optional{, data}} +\begin{funcdesc}{urlopen}{url\optional{, data}\optional{, proxies}} Open a network object denoted by a URL for reading. If the URL does not have a scheme identifier, or if it has \file{file:} as its scheme identifier, this opens a local file; otherwise it opens a socket to a @@ -79,6 +79,23 @@ In a Macintosh environment, \function{urlopen()} will retrieve proxy information from Internet\index{Internet Config} Config. + +Alternatively, the optional \var{proxies} argument may be used to +explicitly specify proxies. It must be a dictionary mapping scheme +names to proxy URLs, where an empty dictionary causes no proxies to be +used, and \code{None} (the default value) causes environmental proxy +settings to be used as discussed above. For example: + +\begin{verbatim} +# Use http://www.someproxy.com:3128 for http proxying +proxies = proxies={'http': 'http://www.someproxy.com:3128'} +filehandle = urllib.urlopen(some_url, proxies=proxies) +# Don't use any proxies +filehandle = urllib.urlopen(some_url, proxies={}) +# Use proxies from environment - both versions are equivalent +filehandle = urllib.urlopen(some_url, proxies=None) +filehandle = urllib.urlopen(some_url) +\end{verbatim} Proxies which require authentication for use are not currently supported; this is considered an implementation limitation. Index: dist/src/Lib/urllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib.py,v retrieving revision 1.136 diff -u -w -r1.136 urllib.py --- dist/src/Lib/urllib.py 11 Feb 2002 18:06:21 -0000 1.136 +++ dist/src/Lib/urllib.py 27 Feb 2002 14:38:57 -0000 @@ -64,11 +64,11 @@ # Shortcut for basic usage _urlopener = None -def urlopen(url, data=None): - """urlopen(url [, data]) -> open file-like object""" +def urlopen(url, data=None, proxies=None): + """urlopen(url [, data] [, proxies]) -> open file-like object""" global _urlopener if not _urlopener: - _urlopener = FancyURLopener() + _urlopener = FancyURLopener(proxies=proxies) if data is None: return _urlopener.open(url) else: