Kaydet (Commit) 806c1c93 authored tarafından R David Murray's avatar R David Murray

#7152: Clarify that ProxyHandler is added only if proxy settings are detected.

Behavior confirmation and initial patch by Jessica McKellar.
üst 8118df7b
...@@ -489,9 +489,10 @@ than the URL you pass to .add_password() will also match. :: ...@@ -489,9 +489,10 @@ than the URL you pass to .add_password() will also match. ::
In the above example we only supplied our ``HTTPBasicAuthHandler`` to In the above example we only supplied our ``HTTPBasicAuthHandler`` to
``build_opener``. By default openers have the handlers for normal situations ``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``, ``HTTPDefaultErrorHandler``, ``HTTPRedirectHandler``, ``FTPHandler``,
``FileHandler``, ``HTTPErrorProcessor``. ``FileHandler``, ``DataHandler``, ``HTTPErrorProcessor``.
``top_level_url`` is in fact *either* a full URL (including the 'http:' scheme ``top_level_url`` is in fact *either* a full URL (including the 'http:' scheme
component and the hostname and optionally the port number) component and the hostname and optionally the port number)
...@@ -506,7 +507,8 @@ Proxies ...@@ -506,7 +507,8 @@ Proxies
======= =======
**urllib2** will auto-detect your proxy settings and use those. This is through **urllib2** 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 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 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 : :: is done using similar steps to setting up a `Basic Authentication`_ handler : ::
......
...@@ -60,8 +60,10 @@ The :mod:`urllib2` module defines the following functions: ...@@ -60,8 +60,10 @@ The :mod:`urllib2` module defines the following functions:
default installed global :class:`OpenerDirector` uses :class:`UnknownHandler` to default installed global :class:`OpenerDirector` uses :class:`UnknownHandler` to
ensure this never happens). ensure this never happens).
In addition, default installed :class:`ProxyHandler` makes sure the requests In addition, if proxy settings are detected (for example, when a ``*_proxy``
are handled through the proxy when they are set. environment variable like :envvar:`http_proxy` is set),
:class:`ProxyHandler` is default installed and makes sure the requests are
handled through the proxy.
.. versionchanged:: 2.6 .. versionchanged:: 2.6
*timeout* was added. *timeout* was added.
...@@ -83,7 +85,8 @@ The :mod:`urllib2` module defines the following functions: ...@@ -83,7 +85,8 @@ The :mod:`urllib2` module defines the following functions:
subclasses of :class:`BaseHandler` (in which case it must be possible to call subclasses of :class:`BaseHandler` (in which case it must be possible to call
the constructor without any parameters). Instances of the following classes the constructor without any parameters). Instances of the following classes
will be in front of the *handler*\s, unless the *handler*\s contain them, 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:`UnknownHandler`, :class:`HTTPHandler`, :class:`HTTPDefaultErrorHandler`,
:class:`HTTPRedirectHandler`, :class:`FTPHandler`, :class:`FileHandler`, :class:`HTTPRedirectHandler`, :class:`FTPHandler`, :class:`FileHandler`,
:class:`HTTPErrorProcessor`. :class:`HTTPErrorProcessor`.
...@@ -202,9 +205,9 @@ The following classes are provided: ...@@ -202,9 +205,9 @@ The following classes are provided:
Cause requests to go through a proxy. If *proxies* is given, it must be a 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 dictionary mapping protocol names to URLs of proxies. The default is to read
the list of proxies from the environment variables the list of proxies from the environment variables
:envvar:`<protocol>_proxy`. If no proxy environment variables are set, in a :envvar:`<protocol>_proxy`. If no proxy environment variables are set, then
Windows environment, proxy settings are obtained from the registry's in a Windows environment proxy settings are obtained from the registry's
Internet Settings section and in a Mac OS X environment, proxy information Internet Settings section, and in a Mac OS X environment proxy information
is retrieved from the OS X System Configuration Framework. is retrieved from the OS X System Configuration Framework.
To disable autodetected proxy pass an empty dictionary. To disable autodetected proxy pass an empty dictionary.
......
...@@ -656,6 +656,7 @@ Kirk McDonald ...@@ -656,6 +656,7 @@ Kirk McDonald
Chris McDonough Chris McDonough
Greg McFarlane Greg McFarlane
Alan McIntyre Alan McIntyre
Jessica McKellar
Michael McLay Michael McLay
Mark Mc Mahon Mark Mc Mahon
Gordon McMillan Gordon McMillan
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment