Back to index

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

List of all members.

Public Member Functions

def __init__
def http_error_default
def http_error_302
def redirect_internal
def http_error_301
def http_error_303
def http_error_307
def http_error_401
def http_error_407
def retry_proxy_http_basic_auth
def retry_proxy_https_basic_auth
def retry_http_basic_auth
def retry_https_basic_auth
def get_user_passwd
def prompt_user_passwd
def close
def cleanup
def addheader
def open
def open_unknown
def open_unknown_proxy
def retrieve
def open_http
def http_error
def open_https
def open_file
def open_local_file
def open_ftp
def open_data

Public Attributes

 auth_cache
 tries
 maxtries
 proxies
 key_file
 cert_file
 addheaders
 tempcache
 ftpcache
 type

Static Public Attributes

string version = "Python-urllib/%s"

Detailed Description

Derived class with handlers for errors we can handle (perhaps).

Definition at line 1891 of file request.py.


Constructor & Destructor Documentation

def urllib.request.FancyURLopener.__init__ (   self,
  args,
  kwargs 
)

Reimplemented from urllib.request.URLopener.

Definition at line 1894 of file request.py.

01894 
01895     def __init__(self, *args, **kwargs):
01896         URLopener.__init__(self, *args, **kwargs)
01897         self.auth_cache = {}
01898         self.tries = 0
01899         self.maxtries = 10

Here is the caller graph for this function:


Member Function Documentation

def urllib.request.URLopener.addheader (   self,
  args 
) [inherited]
Add a header to be used by the HTTP interface only
e.g. u.addheader('Accept', 'sound/basic')

Definition at line 1504 of file request.py.

01504 
01505     def addheader(self, *args):
01506         """Add a header to be used by the HTTP interface only
01507         e.g. u.addheader('Accept', 'sound/basic')"""
01508         self.addheaders.append(args)

def urllib.request.URLopener.cleanup (   self) [inherited]

Definition at line 1490 of file request.py.

01490 
01491     def cleanup(self):
01492         # This code sometimes runs when the rest of this module
01493         # has already been deleted, so it can't use any globals
01494         # or import anything.
01495         if self.__tempfiles:
01496             for file in self.__tempfiles:
01497                 try:
01498                     self.__unlink(file)
01499                 except OSError:
01500                     pass
01501             del self.__tempfiles[:]
01502         if self.tempcache:
01503             self.tempcache.clear()

Here is the caller graph for this function:

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

Definition at line 1487 of file request.py.

01487 
01488     def close(self):
01489         self.cleanup()

Here is the call graph for this function:

Here is the caller graph for this function:

def urllib.request.FancyURLopener.get_user_passwd (   self,
  host,
  realm,
  clear_cache = 0 
)

Definition at line 2080 of file request.py.

02080 
02081     def get_user_passwd(self, host, realm, clear_cache=0):
02082         key = realm + '@' + host.lower()
02083         if key in self.auth_cache:
02084             if clear_cache:
02085                 del self.auth_cache[key]
02086             else:
02087                 return self.auth_cache[key]
02088         user, passwd = self.prompt_user_passwd(host, realm)
02089         if user or passwd: self.auth_cache[key] = (user, passwd)
02090         return user, passwd

Here is the call graph for this function:

Here is the caller graph for this function:

def urllib.request.URLopener.http_error (   self,
  url,
  fp,
  errcode,
  errmsg,
  headers,
  data = None 
) [inherited]
Handle http errors.

Derived class can override this, or provide specific handlers
named http_error_DDD where DDD is the 3-digit error code.

Definition at line 1718 of file request.py.

01718 
01719     def http_error(self, url, fp, errcode, errmsg, headers, data=None):
01720         """Handle http errors.
01721 
01722         Derived class can override this, or provide specific handlers
01723         named http_error_DDD where DDD is the 3-digit error code."""
01724         # First check if there's a specific handler for this error
01725         name = 'http_error_%d' % errcode
01726         if hasattr(self, name):
01727             method = getattr(self, name)
01728             if data is None:
01729                 result = method(url, fp, errcode, errmsg, headers)
01730             else:
01731                 result = method(url, fp, errcode, errmsg, headers, data)
01732             if result: return result
01733         return self.http_error_default(url, fp, errcode, errmsg, headers)

Here is the call graph for this function:

Here is the caller graph for this function:

def urllib.request.FancyURLopener.http_error_301 (   self,
  url,
  fp,
  errcode,
  errmsg,
  headers,
  data = None 
)
Error 301 -- also relocated (permanently).

Definition at line 1949 of file request.py.

01949 
01950     def http_error_301(self, url, fp, errcode, errmsg, headers, data=None):
01951         """Error 301 -- also relocated (permanently)."""
01952         return self.http_error_302(url, fp, errcode, errmsg, headers, data)

Here is the call graph for this function:

def urllib.request.FancyURLopener.http_error_302 (   self,
  url,
  fp,
  errcode,
  errmsg,
  headers,
  data = None 
)
Error 302 -- relocated (temporarily).

Definition at line 1904 of file request.py.

01904 
01905     def http_error_302(self, url, fp, errcode, errmsg, headers, data=None):
01906         """Error 302 -- relocated (temporarily)."""
01907         self.tries += 1
01908         if self.maxtries and self.tries >= self.maxtries:
01909             if hasattr(self, "http_error_500"):
01910                 meth = self.http_error_500
01911             else:
01912                 meth = self.http_error_default
01913             self.tries = 0
01914             return meth(url, fp, 500,
01915                         "Internal Server Error: Redirect Recursion", headers)
01916         result = self.redirect_internal(url, fp, errcode, errmsg, headers,
01917                                         data)
01918         self.tries = 0
01919         return result

Here is the call graph for this function:

Here is the caller graph for this function:

def urllib.request.FancyURLopener.http_error_303 (   self,
  url,
  fp,
  errcode,
  errmsg,
  headers,
  data = None 
)
Error 303 -- also relocated (essentially identical to 302).

Definition at line 1953 of file request.py.

01953 
01954     def http_error_303(self, url, fp, errcode, errmsg, headers, data=None):
01955         """Error 303 -- also relocated (essentially identical to 302)."""
01956         return self.http_error_302(url, fp, errcode, errmsg, headers, data)

Here is the call graph for this function:

def urllib.request.FancyURLopener.http_error_307 (   self,
  url,
  fp,
  errcode,
  errmsg,
  headers,
  data = None 
)
Error 307 -- relocated, but turn POST into error.

Definition at line 1957 of file request.py.

01957 
01958     def http_error_307(self, url, fp, errcode, errmsg, headers, data=None):
01959         """Error 307 -- relocated, but turn POST into error."""
01960         if data is None:
01961             return self.http_error_302(url, fp, errcode, errmsg, headers, data)
01962         else:
01963             return self.http_error_default(url, fp, errcode, errmsg, headers)

Here is the call graph for this function:

def urllib.request.FancyURLopener.http_error_401 (   self,
  url,
  fp,
  errcode,
  errmsg,
  headers,
  data = None,
  retry = False 
)
Error 401 -- authentication required.
This function supports Basic authentication only.

Definition at line 1965 of file request.py.

01965 
01966             retry=False):
01967         """Error 401 -- authentication required.
01968         This function supports Basic authentication only."""
01969         if not 'www-authenticate' in headers:
01970             URLopener.http_error_default(self, url, fp,
01971                                          errcode, errmsg, headers)
01972         stuff = headers['www-authenticate']
01973         import re
01974         match = re.match('[ \t]*([^ \t]+)[ \t]+realm="([^"]*)"', stuff)
01975         if not match:
01976             URLopener.http_error_default(self, url, fp,
01977                                          errcode, errmsg, headers)
01978         scheme, realm = match.groups()
01979         if scheme.lower() != 'basic':
01980             URLopener.http_error_default(self, url, fp,
01981                                          errcode, errmsg, headers)
01982         if not retry:
01983             URLopener.http_error_default(self, url, fp, errcode, errmsg,
01984                     headers)
01985         name = 'retry_' + self.type + '_basic_auth'
01986         if data is None:
01987             return getattr(self,name)(url, realm)
01988         else:
01989             return getattr(self,name)(url, realm, data)

Here is the call graph for this function:

Here is the caller graph for this function:

def urllib.request.FancyURLopener.http_error_407 (   self,
  url,
  fp,
  errcode,
  errmsg,
  headers,
  data = None,
  retry = False 
)
Error 407 -- proxy authentication required.
This function supports Basic authentication only.

Definition at line 1991 of file request.py.

01991 
01992             retry=False):
01993         """Error 407 -- proxy authentication required.
01994         This function supports Basic authentication only."""
01995         if not 'proxy-authenticate' in headers:
01996             URLopener.http_error_default(self, url, fp,
01997                                          errcode, errmsg, headers)
01998         stuff = headers['proxy-authenticate']
01999         import re
02000         match = re.match('[ \t]*([^ \t]+)[ \t]+realm="([^"]*)"', stuff)
02001         if not match:
02002             URLopener.http_error_default(self, url, fp,
02003                                          errcode, errmsg, headers)
02004         scheme, realm = match.groups()
02005         if scheme.lower() != 'basic':
02006             URLopener.http_error_default(self, url, fp,
02007                                          errcode, errmsg, headers)
02008         if not retry:
02009             URLopener.http_error_default(self, url, fp, errcode, errmsg,
02010                     headers)
02011         name = 'retry_proxy_' + self.type + '_basic_auth'
02012         if data is None:
02013             return getattr(self,name)(url, realm)
02014         else:
02015             return getattr(self,name)(url, realm, data)

Here is the call graph for this function:

Here is the caller graph for this function:

def urllib.request.FancyURLopener.http_error_default (   self,
  url,
  fp,
  errcode,
  errmsg,
  headers 
)
Default error handling -- don't raise an exception.

Reimplemented from urllib.request.URLopener.

Definition at line 1900 of file request.py.

01900 
01901     def http_error_default(self, url, fp, errcode, errmsg, headers):
01902         """Default error handling -- don't raise an exception."""
01903         return addinfourl(fp, headers, "http:" + url, errcode)

def urllib.request.URLopener.open (   self,
  fullurl,
  data = None 
) [inherited]
Use URLopener().open(file) instead of open(file, 'r').

Definition at line 1510 of file request.py.

01510 
01511     def open(self, fullurl, data=None):
01512         """Use URLopener().open(file) instead of open(file, 'r')."""
01513         fullurl = unwrap(to_bytes(fullurl))
01514         fullurl = quote(fullurl, safe="%/:=&?~#+!$,;'@()*[]|")
01515         if self.tempcache and fullurl in self.tempcache:
01516             filename, headers = self.tempcache[fullurl]
01517             fp = open(filename, 'rb')
01518             return addinfourl(fp, headers, fullurl)
01519         urltype, url = splittype(fullurl)
01520         if not urltype:
01521             urltype = 'file'
01522         if urltype in self.proxies:
01523             proxy = self.proxies[urltype]
01524             urltype, proxyhost = splittype(proxy)
01525             host, selector = splithost(proxyhost)
01526             url = (host, fullurl) # Signal special case to open_*()
01527         else:
01528             proxy = None
01529         name = 'open_' + urltype
01530         self.type = urltype
01531         name = name.replace('-', '_')
01532         if not hasattr(self, name):
01533             if proxy:
01534                 return self.open_unknown_proxy(proxy, fullurl, data)
01535             else:
01536                 return self.open_unknown(fullurl, data)
01537         try:
01538             if data is None:
01539                 return getattr(self, name)(url)
01540             else:
01541                 return getattr(self, name)(url, data)
01542         except socket.error as msg:
01543             raise IOError('socket error', msg).with_traceback(sys.exc_info()[2])

Here is the call graph for this function:

def urllib.request.URLopener.open_data (   self,
  url,
  data = None 
) [inherited]
Use "data" URL.

Definition at line 1848 of file request.py.

01848 
01849     def open_data(self, url, data=None):
01850         """Use "data" URL."""
01851         if not isinstance(url, str):
01852             raise URLError('data error', 'proxy support for data protocol currently not implemented')
01853         # ignore POSTed data
01854         #
01855         # syntax of data URLs:
01856         # dataurl   := "data:" [ mediatype ] [ ";base64" ] "," data
01857         # mediatype := [ type "/" subtype ] *( ";" parameter )
01858         # data      := *urlchar
01859         # parameter := attribute "=" value
01860         try:
01861             [type, data] = url.split(',', 1)
01862         except ValueError:
01863             raise IOError('data error', 'bad data URL')
01864         if not type:
01865             type = 'text/plain;charset=US-ASCII'
01866         semi = type.rfind(';')
01867         if semi >= 0 and '=' not in type[semi:]:
01868             encoding = type[semi+1:]
01869             type = type[:semi]
01870         else:
01871             encoding = ''
01872         msg = []
01873         msg.append('Date: %s'%time.strftime('%a, %d %b %Y %H:%M:%S GMT',
01874                                             time.gmtime(time.time())))
01875         msg.append('Content-type: %s' % type)
01876         if encoding == 'base64':
01877             import base64
01878             # XXX is this encoding/decoding ok?
01879             data = base64.decodebytes(data.encode('ascii')).decode('latin1')
01880         else:
01881             data = unquote(data)
01882         msg.append('Content-Length: %d' % len(data))
01883         msg.append('')
01884         msg.append(data)
01885         msg = '\n'.join(msg)
01886         headers = email.message_from_string(msg)
01887         f = io.StringIO(msg)
01888         #f.fileno = None     # needed for addinfourl
01889         return addinfourl(f, headers, url)
01890 

Here is the call graph for this function:

def urllib.request.URLopener.open_file (   self,
  url 
) [inherited]
Use local file or FTP depending on form of URL.

Definition at line 1750 of file request.py.

01750 
01751     def open_file(self, url):
01752         """Use local file or FTP depending on form of URL."""
01753         if not isinstance(url, str):
01754             raise URLError('file error', 'proxy support for file protocol currently not implemented')
01755         if url[:2] == '//' and url[2:3] != '/' and url[2:12].lower() != 'localhost/':
01756             raise ValueError("file:// scheme is supported only on localhost")
01757         else:
01758             return self.open_local_file(url)

Here is the call graph for this function:

def urllib.request.URLopener.open_ftp (   self,
  url 
) [inherited]
Use FTP protocol.

Definition at line 1789 of file request.py.

01789 
01790     def open_ftp(self, url):
01791         """Use FTP protocol."""
01792         if not isinstance(url, str):
01793             raise URLError('ftp error', 'proxy support for ftp protocol currently not implemented')
01794         import mimetypes
01795         from io import StringIO
01796         host, path = splithost(url)
01797         if not host: raise URLError('ftp error', 'no host given')
01798         host, port = splitport(host)
01799         user, host = splituser(host)
01800         if user: user, passwd = splitpasswd(user)
01801         else: passwd = None
01802         host = unquote(host)
01803         user = unquote(user or '')
01804         passwd = unquote(passwd or '')
01805         host = socket.gethostbyname(host)
01806         if not port:
01807             import ftplib
01808             port = ftplib.FTP_PORT
01809         else:
01810             port = int(port)
01811         path, attrs = splitattr(path)
01812         path = unquote(path)
01813         dirs = path.split('/')
01814         dirs, file = dirs[:-1], dirs[-1]
01815         if dirs and not dirs[0]: dirs = dirs[1:]
01816         if dirs and not dirs[0]: dirs[0] = '/'
01817         key = user, host, port, '/'.join(dirs)
01818         # XXX thread unsafe!
01819         if len(self.ftpcache) > MAXFTPCACHE:
01820             # Prune the cache, rather arbitrarily
01821             for k in self.ftpcache.keys():
01822                 if k != key:
01823                     v = self.ftpcache[k]
01824                     del self.ftpcache[k]
01825                     v.close()
01826         try:
01827             if not key in self.ftpcache:
01828                 self.ftpcache[key] = \
01829                     ftpwrapper(user, passwd, host, port, dirs)
01830             if not file: type = 'D'
01831             else: type = 'I'
01832             for attr in attrs:
01833                 attr, value = splitvalue(attr)
01834                 if attr.lower() == 'type' and \
01835                    value in ('a', 'A', 'i', 'I', 'd', 'D'):
01836                     type = value.upper()
01837             (fp, retrlen) = self.ftpcache[key].retrfile(file, type)
01838             mtype = mimetypes.guess_type("ftp:" + url)[0]
01839             headers = ""
01840             if mtype:
01841                 headers += "Content-Type: %s\n" % mtype
01842             if retrlen is not None and retrlen >= 0:
01843                 headers += "Content-Length: %d\n" % retrlen
01844             headers = email.message_from_string(headers)
01845             return addinfourl(fp, headers, "ftp:" + url)
01846         except ftperrors() as msg:
01847             raise URLError('ftp error', msg).with_traceback(sys.exc_info()[2])

Here is the call graph for this function:

def urllib.request.URLopener.open_http (   self,
  url,
  data = None 
) [inherited]
Use HTTP protocol.

Definition at line 1714 of file request.py.

01714 
01715     def open_http(self, url, data=None):
01716         """Use HTTP protocol."""
01717         return self._open_generic_http(http.client.HTTPConnection, url, data)

Here is the call graph for this function:

def urllib.request.URLopener.open_https (   self,
  url,
  data = None 
) [inherited]
Use HTTPS protocol.

Definition at line 1746 of file request.py.

01746 
01747         def open_https(self, url, data=None):
01748             """Use HTTPS protocol."""
01749             return self._open_generic_http(self._https_connection, url, data)

Here is the call graph for this function:

def urllib.request.URLopener.open_local_file (   self,
  url 
) [inherited]
Use local file.

Definition at line 1759 of file request.py.

01759 
01760     def open_local_file(self, url):
01761         """Use local file."""
01762         import mimetypes, email.utils
01763         from io import StringIO
01764         host, file = splithost(url)
01765         localname = url2pathname(file)
01766         try:
01767             stats = os.stat(localname)
01768         except OSError as e:
01769             raise URLError(e.errno, e.strerror, e.filename)
01770         size = stats.st_size
01771         modified = email.utils.formatdate(stats.st_mtime, usegmt=True)
01772         mtype = mimetypes.guess_type(url)[0]
01773         headers = email.message_from_string(
01774             'Content-Type: %s\nContent-Length: %d\nLast-modified: %s\n' %
01775             (mtype or 'text/plain', size, modified))
01776         if not host:
01777             urlfile = file
01778             if file[:1] == '/':
01779                 urlfile = 'file://' + file
01780             return addinfourl(open(localname, 'rb'), headers, urlfile)
01781         host, port = splitport(host)
01782         if (not port
01783            and socket.gethostbyname(host) in (localhost() + thishost())):
01784             urlfile = file
01785             if file[:1] == '/':
01786                 urlfile = 'file://' + file
01787             return addinfourl(open(localname, 'rb'), headers, urlfile)
01788         raise URLError('local file error', 'not on local host')

Here is the call graph for this function:

Here is the caller graph for this function:

def urllib.request.URLopener.open_unknown (   self,
  fullurl,
  data = None 
) [inherited]
Overridable interface to open unknown URL type.

Definition at line 1544 of file request.py.

01544 
01545     def open_unknown(self, fullurl, data=None):
01546         """Overridable interface to open unknown URL type."""
01547         type, url = splittype(fullurl)
01548         raise IOError('url error', 'unknown url type', type)

Here is the call graph for this function:

def urllib.request.URLopener.open_unknown_proxy (   self,
  proxy,
  fullurl,
  data = None 
) [inherited]
Overridable interface to open unknown URL type.

Definition at line 1549 of file request.py.

01549 
01550     def open_unknown_proxy(self, proxy, fullurl, data=None):
01551         """Overridable interface to open unknown URL type."""
01552         type, url = splittype(fullurl)
01553         raise IOError('url error', 'invalid proxy for %s' % type, proxy)

Here is the call graph for this function:

def urllib.request.FancyURLopener.prompt_user_passwd (   self,
  host,
  realm 
)
Override this in a GUI environment!

Definition at line 2091 of file request.py.

02091 
02092     def prompt_user_passwd(self, host, realm):
02093         """Override this in a GUI environment!"""
02094         import getpass
02095         try:
02096             user = input("Enter username for %s at %s: " % (realm, host))
02097             passwd = getpass.getpass("Enter password for %s in %s at %s: " %
02098                 (user, realm, host))
02099             return user, passwd
02100         except KeyboardInterrupt:
02101             print()
02102             return None, None
02103 
02104 
02105 # Utility functions

Here is the call graph for this function:

Here is the caller graph for this function:

def urllib.request.FancyURLopener.redirect_internal (   self,
  url,
  fp,
  errcode,
  errmsg,
  headers,
  data 
)

Definition at line 1920 of file request.py.

01920 
01921     def redirect_internal(self, url, fp, errcode, errmsg, headers, data):
01922         if 'location' in headers:
01923             newurl = headers['location']
01924         elif 'uri' in headers:
01925             newurl = headers['uri']
01926         else:
01927             return
01928         void = fp.read()
01929         fp.close()
01930 
01931         # In case the server sent a relative URL, join with original:
01932         newurl = urljoin(self.type + ":" + url, newurl)
01933 
01934         urlparts = urlparse(newurl)
01935 
01936         # For security reasons, we don't allow redirection to anything other
01937         # than http, https and ftp.
01938 
01939         # We are using newer HTTPError with older redirect_internal method
01940         # This older method will get deprecated in 3.3
01941 
01942         if not urlparts.scheme in ('http', 'https', 'ftp'):
01943             raise HTTPError(newurl, errcode,
01944                             errmsg +
01945                             " Redirection to url '%s' is not allowed." % newurl,
01946                             headers, fp)
01947 
01948         return self.open(newurl)

Here is the call graph for this function:

Here is the caller graph for this function:

def urllib.request.URLopener.retrieve (   self,
  url,
  filename = None,
  reporthook = None,
  data = None 
) [inherited]
retrieve(url) returns (filename, headers) for a local object
or (tempfilename, headers) for a remote object.

Definition at line 1555 of file request.py.

01555 
01556     def retrieve(self, url, filename=None, reporthook=None, data=None):
01557         """retrieve(url) returns (filename, headers) for a local object
01558         or (tempfilename, headers) for a remote object."""
01559         url = unwrap(to_bytes(url))
01560         if self.tempcache and url in self.tempcache:
01561             return self.tempcache[url]
01562         type, url1 = splittype(url)
01563         if filename is None and (not type or type == 'file'):
01564             try:
01565                 fp = self.open_local_file(url1)
01566                 hdrs = fp.info()
01567                 fp.close()
01568                 return url2pathname(splithost(url1)[1]), hdrs
01569             except IOError as msg:
01570                 pass
01571         fp = self.open(url, data)
01572         try:
01573             headers = fp.info()
01574             if filename:
01575                 tfp = open(filename, 'wb')
01576             else:
01577                 import tempfile
01578                 garbage, path = splittype(url)
01579                 garbage, path = splithost(path or "")
01580                 path, garbage = splitquery(path or "")
01581                 path, garbage = splitattr(path or "")
01582                 suffix = os.path.splitext(path)[1]
01583                 (fd, filename) = tempfile.mkstemp(suffix)
01584                 self.__tempfiles.append(filename)
01585                 tfp = os.fdopen(fd, 'wb')
01586             try:
01587                 result = filename, headers
01588                 if self.tempcache is not None:
01589                     self.tempcache[url] = result
01590                 bs = 1024*8
01591                 size = -1
01592                 read = 0
01593                 blocknum = 0
01594                 if reporthook:
01595                     if "content-length" in headers:
01596                         size = int(headers["Content-Length"])
01597                     reporthook(blocknum, bs, size)
01598                 while 1:
01599                     block = fp.read(bs)
01600                     if not block:
01601                         break
01602                     read += len(block)
01603                     tfp.write(block)
01604                     blocknum += 1
01605                     if reporthook:
01606                         reporthook(blocknum, bs, size)
01607             finally:
01608                 tfp.close()
01609         finally:
01610             fp.close()
01611 
01612         # raise exception if actual size does not match content-length header
01613         if size >= 0 and read < size:
01614             raise ContentTooShortError(
01615                 "retrieval incomplete: got only %i out of %i bytes"
01616                 % (read, size), result)
01617 
01618         return result

Here is the call graph for this function:

def urllib.request.FancyURLopener.retry_http_basic_auth (   self,
  url,
  realm,
  data = None 
)

Definition at line 2052 of file request.py.

02052 
02053     def retry_http_basic_auth(self, url, realm, data=None):
02054         host, selector = splithost(url)
02055         i = host.find('@') + 1
02056         host = host[i:]
02057         user, passwd = self.get_user_passwd(host, realm, i)
02058         if not (user or passwd): return None
02059         host = "%s:%s@%s" % (quote(user, safe=''),
02060                              quote(passwd, safe=''), host)
02061         newurl = 'http://' + host + selector
02062         if data is None:
02063             return self.open(newurl)
02064         else:
02065             return self.open(newurl, data)

Here is the call graph for this function:

def urllib.request.FancyURLopener.retry_https_basic_auth (   self,
  url,
  realm,
  data = None 
)

Definition at line 2066 of file request.py.

02066 
02067     def retry_https_basic_auth(self, url, realm, data=None):
02068         host, selector = splithost(url)
02069         i = host.find('@') + 1
02070         host = host[i:]
02071         user, passwd = self.get_user_passwd(host, realm, i)
02072         if not (user or passwd): return None
02073         host = "%s:%s@%s" % (quote(user, safe=''),
02074                              quote(passwd, safe=''), host)
02075         newurl = 'https://' + host + selector
02076         if data is None:
02077             return self.open(newurl)
02078         else:
02079             return self.open(newurl, data)

Here is the call graph for this function:

def urllib.request.FancyURLopener.retry_proxy_http_basic_auth (   self,
  url,
  realm,
  data = None 
)

Definition at line 2016 of file request.py.

02016 
02017     def retry_proxy_http_basic_auth(self, url, realm, data=None):
02018         host, selector = splithost(url)
02019         newurl = 'http://' + host + selector
02020         proxy = self.proxies['http']
02021         urltype, proxyhost = splittype(proxy)
02022         proxyhost, proxyselector = splithost(proxyhost)
02023         i = proxyhost.find('@') + 1
02024         proxyhost = proxyhost[i:]
02025         user, passwd = self.get_user_passwd(proxyhost, realm, i)
02026         if not (user or passwd): return None
02027         proxyhost = "%s:%s@%s" % (quote(user, safe=''),
02028                                   quote(passwd, safe=''), proxyhost)
02029         self.proxies['http'] = 'http://' + proxyhost + proxyselector
02030         if data is None:
02031             return self.open(newurl)
02032         else:
02033             return self.open(newurl, data)

Here is the call graph for this function:

def urllib.request.FancyURLopener.retry_proxy_https_basic_auth (   self,
  url,
  realm,
  data = None 
)

Definition at line 2034 of file request.py.

02034 
02035     def retry_proxy_https_basic_auth(self, url, realm, data=None):
02036         host, selector = splithost(url)
02037         newurl = 'https://' + host + selector
02038         proxy = self.proxies['https']
02039         urltype, proxyhost = splittype(proxy)
02040         proxyhost, proxyselector = splithost(proxyhost)
02041         i = proxyhost.find('@') + 1
02042         proxyhost = proxyhost[i:]
02043         user, passwd = self.get_user_passwd(proxyhost, realm, i)
02044         if not (user or passwd): return None
02045         proxyhost = "%s:%s@%s" % (quote(user, safe=''),
02046                                   quote(passwd, safe=''), proxyhost)
02047         self.proxies['https'] = 'https://' + proxyhost + proxyselector
02048         if data is None:
02049             return self.open(newurl)
02050         else:
02051             return self.open(newurl, data)

Here is the call graph for this function:


Member Data Documentation

Definition at line 1468 of file request.py.

Definition at line 1896 of file request.py.

Definition at line 1467 of file request.py.

Definition at line 1478 of file request.py.

Definition at line 1466 of file request.py.

Definition at line 1898 of file request.py.

Definition at line 1465 of file request.py.

Definition at line 1471 of file request.py.

Definition at line 1897 of file request.py.

Definition at line 1529 of file request.py.

string urllib.request.URLopener.version = "Python-urllib/%s" [static, inherited]

Definition at line 1458 of file request.py.


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