[Python-checkins] cpython (merge 3.3 -> default): Merge #7152: Clarify that ProxyHandler is added only if proxy settings are
r.david.murray
python-checkins at python.org
Sun Apr 28 17:31:28 CEST 2013
http://hg.python.org/cpython/rev/aca80409ecdd
changeset: 83536:aca80409ecdd
parent: 83534:65487938643d
parent: 83535:f2472fb98457
user: R David Murray <rdmurray at bitdance.com>
date: Sun Apr 28 11:08:27 2013 -0400
summary:
Merge #7152: Clarify that ProxyHandler is added only if proxy settings are detected.
Behavior confirmation and initial patch by Jessica McKellar.
files:
Doc/howto/urllib2.rst | 8 +++++---
Doc/library/urllib.request.rst | 15 +++++++++------
Misc/ACKS | 1 +
3 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/Doc/howto/urllib2.rst b/Doc/howto/urllib2.rst
--- a/Doc/howto/urllib2.rst
+++ b/Doc/howto/urllib2.rst
@@ -504,9 +504,10 @@
In the above example we only supplied our ``HTTPBasicAuthHandler`` to
``build_opener``. By default openers have the handlers for normal situations
- -- ``ProxyHandler``, ``UnknownHandler``, ``HTTPHandler``,
+ -- ``ProxyHandler`` (if a proxy setting such as an :envvar:`http_proxy`
+ environment variable is set), ``UnknownHandler``, ``HTTPHandler``,
``HTTPDefaultErrorHandler``, ``HTTPRedirectHandler``, ``FTPHandler``,
- ``FileHandler``, ``HTTPErrorProcessor``.
+ ``FileHandler``, ``DataHandler``, ``HTTPErrorProcessor``.
``top_level_url`` is in fact *either* a full URL (including the 'http:' scheme
component and the hostname and optionally the port number)
@@ -521,7 +522,8 @@
=======
**urllib** will auto-detect your proxy settings and use those. This is through
-the ``ProxyHandler`` which is part of the normal handler chain. Normally that's
+the ``ProxyHandler``, which is part of the normal handler chain when a proxy
+setting is detected. Normally that's
a good thing, but there are occasions when it may not be helpful [#]_. One way
to do this is to setup our own ``ProxyHandler``, with no proxies defined. This
is done using similar steps to setting up a `Basic Authentication`_ handler : ::
diff --git a/Doc/library/urllib.request.rst b/Doc/library/urllib.request.rst
--- a/Doc/library/urllib.request.rst
+++ b/Doc/library/urllib.request.rst
@@ -87,8 +87,10 @@
the default installed global :class:`OpenerDirector` uses
:class:`UnknownHandler` to ensure this never happens).
- In addition, default installed :class:`ProxyHandler` makes sure the requests
- are handled through the proxy when they are set.
+ In addition, if proxy settings are detected (for example, when a ``*_proxy``
+ environment variable like :envvar:`http_proxy` is set),
+ :class:`ProxyHandler` is default installed and makes sure the requests are
+ handled through the proxy.
The legacy ``urllib.urlopen`` function from Python 2.6 and earlier has been
discontinued; :func:`urllib.request.urlopen` corresponds to the old
@@ -126,7 +128,8 @@
subclasses of :class:`BaseHandler` (in which case it must be possible to call
the constructor without any parameters). Instances of the following classes
will be in front of the *handler*\s, unless the *handler*\s contain them,
- instances of them or subclasses of them: :class:`ProxyHandler`,
+ instances of them or subclasses of them: :class:`ProxyHandler` (if proxy
+ settings are detected),
:class:`UnknownHandler`, :class:`HTTPHandler`, :class:`HTTPDefaultErrorHandler`,
:class:`HTTPRedirectHandler`, :class:`FTPHandler`, :class:`FileHandler`,
:class:`HTTPErrorProcessor`, :class:`DataHandler`.
@@ -256,9 +259,9 @@
Cause requests to go through a proxy. If *proxies* is given, it must be a
dictionary mapping protocol names to URLs of proxies. The default is to read the
list of proxies from the environment variables :envvar:`<protocol>_proxy`.
- If no proxy environment variables are set, in a Windows environment, proxy
- settings are obtained from the registry's Internet Settings section and in a
- Mac OS X environment, proxy information is retrieved from the OS X System
+ If no proxy environment variables are set, then in a Windows environment proxy
+ settings are obtained from the registry's Internet Settings section, and in a
+ Mac OS X environment proxy information is retrieved from the OS X System
Configuration Framework.
To disable autodetected proxy pass an empty dictionary.
diff --git a/Misc/ACKS b/Misc/ACKS
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -804,6 +804,7 @@
Chris McDonough
Greg McFarlane
Alan McIntyre
+Jessica McKellar
Michael McLay
Brendan McLoughlin
Mark Mc Mahon
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list