Lines Matching +full:decode +full:- +full:uri +full:- +full:component
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"})
78 # check digest against correct (i.e. non-apache) implementation
135 # used in User-Agent header sent
173 msg attribute contains the same information as the reason attribute ---
174 the reason phrase returned by the server --- instead of the response
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
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
693 # (so probably same goes for URI). Use first header.
696 elif "uri" in headers:
697 newurl = headers["uri"]
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
761 If a URL is supplied, it must have an authority (host:port) component.
762 According to RFC 3986, having an authority component means the URL must
774 # We have an authority, so for RFC 3986-compliant URLs (by ss 3.
781 if end == -1:
818 creds = base64.b64encode(user_pass.encode()).decode("ascii")
819 req.add_header('Proxy-authorization', 'Basic ' + creds)
839 def add_password(self, realm, uri, user, passwd): argument
840 # uri could be a single URI or a sequence
841 if isinstance(uri, str):
842 uri = [uri]
847 self.reduce_uri(u, default_port) for u in uri)
855 for uri in uris:
856 if self.is_suburi(uri, reduced_authuri):
860 def reduce_uri(self, uri, default_port=True): argument
861 """Accept authority or URI and extract only the authority and path."""
862 # note HTTP URLs do not have a userinfo component
863 parts = urlsplit(uri)
865 # URI
872 authority = uri
884 """Check if test is below base in a URI tree
893 if prefix[-1:] != '/':
914 def add_password(self, realm, uri, user, passwd, is_authenticated=False): argument
915 self.update_authenticated(uri, is_authenticated)
918 super().add_password(None, uri, user, passwd)
919 super().add_password(realm, uri, user, passwd)
921 def update_authenticated(self, uri, is_authenticated=False): argument
922 # uri could be a single URI or a sequence
923 if isinstance(uri, str):
924 uri = [uri]
927 for u in uri:
934 for uri in self.authenticated:
935 if self.is_suburi(uri, reduced_authuri):
936 return self.authenticated[uri]
941 # XXX this allows for multiple auth-schemes, but will stupidly pick
944 # allow for double- and single-quoted realm values
956 # XXX could pre-emptively send auth info already accepted (RFC 2617,
967 # parse WWW-Authenticate header: accept multiple challenges per header
1016 auth = "Basic " + base64.b64encode(raw.encode()).decode("ascii")
1032 auth_str = base64.standard_b64encode(credentials).decode()
1056 response = self.http_error_auth_reqed('www-authenticate',
1063 auth_header = 'Proxy-authorization'
1066 # http_error_auth_reqed requires that there is no userinfo component in
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
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.
1196 base = 'username="%s", realm="%s", nonce="%s", uri="%s", ' \
1214 # XXX MD5-sess
1238 retry = self.http_error_auth_reqed('www-authenticate',
1246 auth_header = 'Proxy-Authorization'
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.
1510 'Content-type: %s\nContent-length: %d\nLast-modified: %s\n' %
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" %
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', '*/*')]
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.
1915 proxy_auth = base64.b64encode(proxy_passwd.encode()).decode('ascii')
1921 auth = base64.b64encode(user_passwd.encode()).decode('ascii')
1927 headers["Proxy-Authorization"] = "Basic %s" % proxy_auth
1942 headers["Content-Type"] = "application/x-www-form-urlencoded"
1971 named http_error_DDD where DDD is the 3-digit error code."""
2021 'Content-Type: %s\nContent-Length: %d\nLast-modified: %s\n' %
2062 dirs, file = dirs[:-1], dirs[-1]
2089 headers += "Content-Type: %s\n" % mtype
2091 headers += "Content-Length: %d\n" % retrlen
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)."""
2173 elif 'uri' in headers:
2174 newurl = headers['uri']
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.
2224 if 'www-authenticate' not in headers:
2227 stuff = headers['www-authenticate']
2247 """Error 407 -- proxy authentication required.
2249 if 'proxy-authenticate' not in headers:
2252 stuff = headers['proxy-authenticate']
2487 self.refcount -= 1
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!
2717 """Return a dictionary of scheme -> proxy server URL mappings.
2729 # Std modules, so should be around - but you never know!