Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
ProxyHandler Class Reference
Inheritance diagram for ProxyHandler:
BaseHandler

Public Member Functions

def __init__
 
def proxy_open
 
- Public Member Functions inherited from BaseHandler
def add_parent
 
def close
 

Data Fields

 proxies
 
- Data Fields inherited from BaseHandler
 parent
 

Detailed Description

Definition at line 442 of file urllib2.py.

Constructor & Destructor Documentation

def __init__ (   self,
  proxies = None 
)

Definition at line 443 of file urllib2.py.

References urllib.getproxies.

444  def __init__(self, proxies=None):
445  if proxies is None:
446  proxies = getproxies()
447  assert hasattr(proxies, 'has_key'), "proxies must be a mapping"
448  self.proxies = proxies
449  for type, url in proxies.items():
450  setattr(self, '%s_open' % type,
451  lambda r, proxy=url, type=type, meth=self.proxy_open: \
452  meth(r, proxy, type))

Member Function Documentation

def proxy_open (   self,
  req,
  proxy,
  type 
)

Definition at line 453 of file urllib2.py.

References base64.encodestring(), urllib.splithost(), urllib.splittype(), string.strip(), and rfc822.unquote().

454  def proxy_open(self, req, proxy, type):
455  orig_type = req.get_type()
456  type, r_type = splittype(proxy)
457  host, XXX = splithost(r_type)
458  if '@' in host:
459  user_pass, host = host.split('@', 1)
460  user_pass = base64.encodestring(unquote(user_pass)).strip()
461  req.add_header('Proxy-Authorization', 'Basic '+user_pass)
462  host = unquote(host)
463  req.set_proxy(host, type)
464  if orig_type == type:
465  # let other handlers take care of it
466  # XXX this only makes sense if the proxy is before the
467  # other handlers
468  return None
469  else:
470  # need to start over, because the other handlers don't
471  # grok the proxy's URL type
472  return self.parent.open(req)
473 
474 # feature suggested by Duncan Booth
# XXX custom is not a good name

Field Documentation

proxies

Definition at line 447 of file urllib2.py.


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