Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes
urllib.request.ProxyHandler Class Reference
Inheritance diagram for urllib.request.ProxyHandler:
Inheritance graph
[legend]
Collaboration diagram for urllib.request.ProxyHandler:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def proxy_open
def add_parent
def close
def __lt__

Public Attributes

 proxies
 parent

Static Public Attributes

int handler_order = 100

Detailed Description

Definition at line 674 of file request.py.


Constructor & Destructor Documentation

def urllib.request.ProxyHandler.__init__ (   self,
  proxies = None 
)

Definition at line 678 of file request.py.

00678 
00679     def __init__(self, proxies=None):
00680         if proxies is None:
00681             proxies = getproxies()
00682         assert hasattr(proxies, 'keys'), "proxies must be a mapping"
00683         self.proxies = proxies
00684         for type, url in proxies.items():
00685             setattr(self, '%s_open' % type,
00686                     lambda r, proxy=url, type=type, meth=self.proxy_open: \
00687                     meth(r, proxy, type))

Here is the caller graph for this function:


Member Function Documentation

def urllib.request.BaseHandler.__lt__ (   self,
  other 
) [inherited]

Definition at line 467 of file request.py.

00467 
00468     def __lt__(self, other):
00469         if not hasattr(other, "handler_order"):
00470             # Try to preserve the old behavior of having custom classes
00471             # inserted after default ones (works only for custom user
00472             # classes which are not aware of handler_order).
00473             return True
00474         return self.handler_order < other.handler_order
00475 

def urllib.request.BaseHandler.add_parent (   self,
  parent 
) [inherited]

Definition at line 460 of file request.py.

00460 
00461     def add_parent(self, parent):
00462         self.parent = parent

def urllib.request.BaseHandler.close (   self) [inherited]

Definition at line 463 of file request.py.

00463 
00464     def close(self):
00465         # Only exists for backwards compatibility
00466         pass

Here is the caller graph for this function:

def urllib.request.ProxyHandler.proxy_open (   self,
  req,
  proxy,
  type 
)

Definition at line 688 of file request.py.

00688 
00689     def proxy_open(self, req, proxy, type):
00690         orig_type = req.type
00691         proxy_type, user, password, hostport = _parse_proxy(proxy)
00692         if proxy_type is None:
00693             proxy_type = orig_type
00694 
00695         if req.host and proxy_bypass(req.host):
00696             return None
00697 
00698         if user and password:
00699             user_pass = '%s:%s' % (unquote(user),
00700                                    unquote(password))
00701             creds = base64.b64encode(user_pass.encode()).decode("ascii")
00702             req.add_header('Proxy-authorization', 'Basic ' + creds)
00703         hostport = unquote(hostport)
00704         req.set_proxy(hostport, proxy_type)
00705         if orig_type == proxy_type or orig_type == 'https':
00706             # let other handlers take care of it
00707             return None
00708         else:
00709             # need to start over, because the other handlers don't
00710             # grok the proxy's URL type
00711             # e.g. if we have a constructor arg proxies like so:
00712             # {'http': 'ftp://proxy.example.com'}, we may end up turning
00713             # a request for http://acme.example.com/a into one for
00714             # ftp://proxy.example.com/a
00715             return self.parent.open(req, timeout=req.timeout)

Here is the call graph for this function:


Member Data Documentation

Reimplemented from urllib.request.BaseHandler.

Definition at line 676 of file request.py.

Definition at line 461 of file request.py.

Definition at line 682 of file request.py.


The documentation for this class was generated from the following file: