~ubuntu-branches/ubuntu/saucy/python2.7/saucy-proposed

« back to all changes in this revision

Viewing changes to Doc/howto/urllib2.rst

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2013-05-15 19:15:16 UTC
  • mto: (36.1.23 sid)
  • mto: This revision was merged to the branch mainline in revision 87.
  • Revision ID: package-import@ubuntu.com-20130515191516-zmv6to904wemey7s
Tags: upstream-2.7.5
ImportĀ upstreamĀ versionĀ 2.7.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
489
489
 
490
490
    In the above example we only supplied our ``HTTPBasicAuthHandler`` to
491
491
    ``build_opener``. By default openers have the handlers for normal situations
492
 
    -- ``ProxyHandler``, ``UnknownHandler``, ``HTTPHandler``,
 
492
    -- ``ProxyHandler`` (if a proxy setting such as an :envvar:`http_proxy`
 
493
    environment variable is set), ``UnknownHandler``, ``HTTPHandler``,
493
494
    ``HTTPDefaultErrorHandler``, ``HTTPRedirectHandler``, ``FTPHandler``,
494
495
    ``FileHandler``, ``HTTPErrorProcessor``.
495
496
 
506
507
=======
507
508
 
508
509
**urllib2** will auto-detect your proxy settings and use those. This is through
509
 
the ``ProxyHandler`` which is part of the normal handler chain. Normally that's
510
 
a good thing, but there are occasions when it may not be helpful [#]_. One way
511
 
to do this is to setup our own ``ProxyHandler``, with no proxies defined. This
512
 
is done using similar steps to setting up a `Basic Authentication`_ handler : ::
 
510
the ``ProxyHandler``, which is part of the normal handler chain when a proxy
 
511
setting is detected.  Normally that's a good thing, but there are occasions
 
512
when it may not be helpful [#]_. One way to do this is to setup our own
 
513
``ProxyHandler``, with no proxies defined. This is done using similar steps to
 
514
setting up a `Basic Authentication`_ handler : ::
513
515
 
514
516
    >>> proxy_support = urllib2.ProxyHandler({})
515
517
    >>> opener = urllib2.build_opener(proxy_support)