Lines Matching +full:basic +full:- +full:ftp
5 below). It opens the URL and returns the results as file-like
13 non-error returns. The HTTPRedirectHandler automatically deals with
17 urlopen(url, data=None) -- Basic usage is the same as original
19 get a file-like object back. One difference is that you can also pass
24 build_opener -- Function that creates a new OpenerDirector instance.
30 install_opener -- Installs a new opener as the default opener.
34 OpenerDirector -- Sets up the User Agent as the Python-urllib client and manages
37 Request -- An object that encapsulates the state of a request. The
39 headers, e.g. a User-Agent.
41 BaseHandler --
54 uri='https://mahler:8092/site-updates.py',
58 proxy_support = urllib.request.ProxyHandler({"http" : "http://ahad-haam:3128"})
60 # build a new opener that adds authentication and caching FTP handlers
77 # ftp errors aren't handled cleanly
78 # check digest against correct (i.e. non-apache) implementation
135 # used in User-Agent header sent
153 HTTPS and FTP connections.
173 msg attribute contains the same information as the reason attribute ---
174 the reason phrase returned by the server --- instead of the response
177 For FTP, file, and data URLs and requests explicitly handled by legacy
260 size = -1
263 if "content-length" in headers:
264 size = int(headers["Content-Length"])
302 """Return request-host, as defined by RFC 2965.
345 # unwrap('<URL:type://host/path>') --> 'type://host/path'
365 # if we change data we need to remove content-length header
367 if self.has_header("Content-length"):
368 self.remove_header("Content-length")
428 client_version = "Python-urllib/%s" % __version__
429 self.addheaders = [('User-agent', client_version)]
512 # pre-process request
521 # post-process response
546 # XXX http[s] protocols are special-cased
573 for HTTP, FTP and when applicable HTTPS.
659 perform the redirect. Otherwise, raise HTTPError if no-one
679 CONTENT_HEADERS = ("content-length", "content-type")
689 # have already seen. Do this by adding a handler-specific
705 # than http, https or ftp.
707 if urlparts.scheme not in ('http', 'https', 'ftp', ''):
710 "%s - Redirection to url '%s' is not allowed" % (msg, newurl),
718 # http.client.parse_headers() decodes as ISO-8859-1. Recover the
719 # original bytes and percent-encode non-ASCII bytes, and any special
722 newurl, encoding="iso-8859-1", safe=string.punctuation)
727 # handlers that also use handler-specific request attributes
774 # We have an authority, so for RFC 3986-compliant URLs (by ss 3.
781 if end == -1:
819 req.add_header('Proxy-authorization', 'Basic ' + creds)
829 # {'http': 'ftp://proxy.example.com'}, we may end up turning
831 # ftp://proxy.example.com/a
893 if prefix[-1:] != '/':
941 # XXX this allows for multiple auth-schemes, but will stupidly pick
944 # allow for double- and single-quoted realm values
948 '([^ \t,]+)' # scheme like "Basic"
956 # XXX could pre-emptively send auth info already accepted (RFC 2617,
967 # parse WWW-Authenticate header: accept multiple challenges per header
972 warnings.warn("Basic Auth Realm was unquoted",
997 if scheme.lower() != 'basic':
1002 # Use the first matching Basic challenge.
1003 # Ignore following challenges even if they use the Basic
1016 auth = "Basic " + base64.b64encode(raw.encode()).decode("ascii")
1034 'Basic {}'.format(auth_str.strip()))
1056 response = self.http_error_auth_reqed('www-authenticate',
1063 auth_header = 'Proxy-authorization'
1071 response = self.http_error_auth_reqed('proxy-authenticate',
1083 # XXX The client does not inspect the Authentication-Info header
1089 # XXX qop="auth-int" supports is shaky
1106 # Don't fail endlessly - if we failed once, we'll probably
1119 elif scheme.lower() != 'basic':
1136 # The cnonce-value is an opaque
1176 … # NOTE: As per RFC 2617, when server sends "auth,auth-int", the client could use either `auth`
1177 # or `auth-int` to the response back. we use `auth` to send the response back.
1191 # XXX handle auth-int.
1214 # XXX MD5-sess
1229 Digest authentication improves on basic authentication because it
1234 handler_order = 490 # before Basic auth
1238 retry = self.http_error_auth_reqed('www-authenticate',
1246 auth_header = 'Proxy-Authorization'
1247 handler_order = 490 # before Basic auth
1251 retry = self.http_error_auth_reqed('proxy-authenticate',
1280 if not request.has_header('Content-type'):
1282 'Content-type',
1283 'application/x-www-form-urlencoded')
1284 if (not request.has_header('Content-length')
1285 and not request.has_header('Transfer-encoding')):
1289 'Content-length', str(content_length))
1292 'Transfer-encoding', 'chunked')
1338 proxy_auth_hdr = "Proxy-Authorization"
1341 # Proxy-Authorization should not be sent to origin
1349 encode_chunked=req.has_header('Transfer-encoding'))
1426 if v[0] == '"' and v[-1] == '"':
1427 v = v[1:-1]
1434 In particular, parse comma-separated lists where the elements of
1435 the list may include quoted-strings. A quoted-string could
1436 contain a comma. A non-quoted string could have quotes in the
1438 Only double-quotes count, not single-quotes.
1475 # Use local file or FTP depending on form of URL
1510 'Content-type: %s\nContent-length: %d\nLast-modified: %s\n' %
1537 raise URLError('ftp error: no host given')
1561 dirs, file = dirs[:-1], dirs[-1]
1576 headers += "Content-type: %s\n" % mtype
1578 headers += "Content-length: %d\n" % retrlen
1661 mediatype = mediatype[:-7]
1664 mediatype = "text/plain;charset=US-ASCII"
1666 headers = email.message_from_string("Content-type: %s\nContent-length: %d\n" %
1674 MAXFTPCACHE = 10 # Trim the ftp cache beyond this size
1676 # Helper for non-unix systems
1681 """OS-specific conversion from a relative URL of the 'file' scheme
1686 """OS-specific conversion from a file system path to a relative URL
1697 more than one set of global protocol-specific options.
1698 Note -- this is a base class for those who don't want the
1704 version = "Python-urllib/%s" % __version__
1717 self.addheaders = [('User-Agent', self.version), ('Accept', '*/*')]
1729 # ftp cache by assigning to the .ftpcache member;
1755 e.g. u.addheader('Accept', 'sound/basic')"""
1779 name = name.replace('-', '_')
1840 size = -1
1843 if "content-length" in headers:
1844 size = int(headers["Content-Length"])
1861 # raise exception if actual size does not match content-length header
1878 - connection_factory should take a host name and return an
1880 - url is the url to retrieval or a host, relative-path pair.
1881 - data is payload for a POST request or None.
1927 headers["Proxy-Authorization"] = "Basic %s" % proxy_auth
1929 headers["Authorization"] = "Basic %s" % auth
1942 headers["Content-Type"] = "application/x-www-form-urlencoded"
1971 named http_error_DDD where DDD is the 3-digit error code."""
1999 """Use local file or FTP depending on form of URL."""
2021 'Content-Type: %s\nContent-Length: %d\nLast-modified: %s\n' %
2040 """Use FTP protocol."""
2042 raise URLError('ftp error: proxy support for ftp protocol currently not implemented')
2045 if not host: raise URLError('ftp error: no host given')
2062 dirs, file = dirs[:-1], dirs[-1]
2086 mtype = mimetypes.guess_type("ftp:" + url)[0]
2089 headers += "Content-Type: %s\n" % mtype
2091 headers += "Content-Length: %d\n" % retrlen
2093 return addinfourl(fp, headers, "ftp:" + url)
2095 raise URLError(f'ftp error: {exp}') from exp
2113 type = 'text/plain;charset=US-ASCII'
2123 msg.append('Content-type: %s' % type)
2126 data = base64.decodebytes(data.encode('ascii')).decode('latin-1')
2129 msg.append('Content-Length: %d' % len(data))
2149 """Default error handling -- don't raise an exception."""
2153 """Error 302 -- relocated (temporarily)."""
2185 # than http, https and ftp.
2190 if urlparts.scheme not in ('http', 'https', 'ftp', ''):
2199 """Error 301 -- also relocated (permanently)."""
2203 """Error 303 -- also relocated (essentially identical to 302)."""
2207 """Error 307 -- relocated, but turn POST into error."""
2214 """Error 308 -- relocated, but turn POST into error."""
2222 """Error 401 -- authentication required.
2223 This function supports Basic authentication only."""
2224 if 'www-authenticate' not in headers:
2227 stuff = headers['www-authenticate']
2233 if scheme.lower() != 'basic':
2247 """Error 407 -- proxy authentication required.
2248 This function supports Basic authentication only."""
2249 if 'proxy-authenticate' not in headers:
2252 stuff = headers['proxy-authenticate']
2258 if scheme.lower() != 'basic':
2381 """Return the set of errors raised by the FTP class."""
2400 """Class used by open_ftp() for cache of open FTP connections."""
2421 self.ftp = ftplib.FTP()
2422 self.ftp.connect(self.host, self.port, self.timeout)
2423 self.ftp.login(self.user, self.passwd)
2425 self.ftp.cwd(_target)
2433 self.ftp.voidcmd(cmd)
2436 self.ftp.voidcmd(cmd)
2442 conn, retrlen = self.ftp.ntransfercmd(cmd)
2445 raise URLError(f'ftp error: {reason}') from reason
2448 self.ftp.voidcmd('TYPE A')
2451 pwd = self.ftp.pwd()
2454 self.ftp.cwd(file)
2456 raise URLError('ftp error: %r' % reason) from reason
2458 self.ftp.cwd(pwd)
2462 conn, retrlen = self.ftp.ntransfercmd(cmd)
2476 self.ftp.voidresp()
2487 self.refcount -= 1
2494 self.ftp.close()
2500 """Return a dictionary of scheme -> proxy server URL mappings.
2513 if value and name[-6:] == '_proxy':
2514 proxies[name[:-6]] = value
2515 # CVE-2016-1000110 - If we are running as CGI script, forget HTTP_PROXY
2516 # (non-all-lowercase) as it may be set from the web server by a "Proxy:"
2522 if name[-6:] == '_proxy':
2525 proxies[name[:-6]] = value
2527 proxies.pop(name[:-6], None)
2621 mask = 32 - mask
2640 """Return a dictionary of scheme -> proxy server URL mappings.
2668 """Return a dictionary of scheme -> proxy server URL mappings.
2677 # Std module, so should be around - but you never know!
2690 proxyServer = 'http={0};https={0};ftp={0}'.format(proxyServer)
2696 if protocol in ('http', 'https', 'ftp'):
2717 """Return a dictionary of scheme -> proxy server URL mappings.
2729 # Std modules, so should be around - but you never know!