Lines Matching +full:- +full:- +full:host
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.
309 host = urlparse(url)[1]
310 if host == "":
311 host = request.get_header("Host", "")
314 host = _cut_port_re.sub("", host, 1)
315 return host.lower()
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")
378 self.host, self.selector = _splithost(rest)
379 if self.host:
380 self.host = unquote(self.host)
390 def set_proxy(self, host, type): argument
392 self._tunnel_host = self.host
396 self.host = host
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
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
759 """Return (scheme, user, password, host/port) given a URL or an authority.
761 If a URL is supplied, it must have an authority (host:port) component.
774 # We have an authority, so for RFC 3986-compliant URLs (by ss 3.
781 if end == -1:
812 if req.host and proxy_bypass(req.host):
819 req.add_header('Proxy-authorization', 'Basic ' + creds)
870 # host or host:port
874 host, port = _splitport(authority)
880 authority = "%s:%d" % (host, dport)
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
956 # XXX could pre-emptively send auth info already accepted (RFC 2617,
967 # parse WWW-Authenticate header: accept multiple challenges per header
986 def http_error_auth_reqed(self, authreq, host, req, headers): argument
987 # host may be an authority (without userinfo) or a URL with an
1005 return self.retry_http_basic_auth(host, req, realm)
1012 def retry_http_basic_auth(self, host, req, realm): argument
1013 user, pw = self.passwd.find_user_password(realm, host)
1056 response = self.http_error_auth_reqed('www-authenticate',
1063 auth_header = 'Proxy-authorization'
1070 authority = req.host
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
1103 def http_error_auth_reqed(self, auth_header, host, req, headers): argument
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.
1214 # XXX MD5-sess
1237 host = urlparse(req.full_url)[1]
1238 retry = self.http_error_auth_reqed('www-authenticate',
1239 host, req, headers)
1246 auth_header = 'Proxy-Authorization'
1250 host = req.host
1251 retry = self.http_error_auth_reqed('proxy-authenticate',
1252 host, req, headers)
1270 host = request.host
1271 if not host:
1272 raise URLError('no host given')
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')
1294 sel_host = host
1298 if not request.has_header('Host'):
1299 request.add_unredirected_header('Host', sel_host)
1312 host = req.host
1313 if not host:
1314 raise URLError('no host given')
1316 # will parse host:port
1317 h = http_class(host, timeout=req.timeout, **http_conn_args)
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.
1478 if url[:2] == '//' and url[2:3] != '/' and (req.host and
1479 req.host != 'localhost'):
1480 if not req.host in self.get_names():
1501 host = req.host
1510 'Content-type: %s\nContent-length: %d\nLast-modified: %s\n' %
1512 if host:
1513 host, port = _splitport(host)
1514 if not host or \
1515 (not port and _safe_gethostbyname(host) in self.get_names()):
1516 if host:
1517 origurl = 'file://' + host + filename
1523 raise URLError('file not on local host')
1525 def _safe_gethostbyname(host): argument
1527 return socket.gethostbyname(host)
1535 host = req.host
1536 if not host:
1537 raise URLError('ftp error: no host given')
1538 host, port = _splitport(host)
1545 user, host = _splituser(host)
1550 host = unquote(host)
1555 host = socket.gethostbyname(host)
1561 dirs, file = dirs[:-1], dirs[-1]
1565 fw = self.connect_ftp(user, passwd, host, port, dirs, req.timeout)
1576 headers += "Content-type: %s\n" % mtype
1578 headers += "Content-length: %d\n" % retrlen
1584 def connect_ftp(self, user, passwd, host, port, dirs, timeout): argument
1585 return ftpwrapper(user, passwd, host, port, dirs, timeout,
1604 def connect_ftp(self, user, passwd, host, port, dirs, timeout): argument
1605 key = user, host, port, '/'.join(dirs), timeout
1609 self.cache[key] = ftpwrapper(user, passwd, host, port,
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', '*/*')]
1773 host, selector = _splithost(proxyhost)
1774 url = (host, fullurl) # Signal special case to open_*()
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.
1887 host, selector = _splithost(url)
1888 if host:
1889 user_passwd, host = _splituser(host)
1890 host = unquote(host)
1891 realhost = host
1893 host, selector = url
1895 proxy_passwd, host = _splituser(host)
1909 host = realhost
1911 if not host: raise OSError('http error', 'no host given')
1924 http_conn = connection_factory(host)
1927 headers["Proxy-Authorization"] = "Basic %s" % proxy_auth
1931 headers["Host"] = realhost
1942 headers["Content-Type"] = "application/x-www-form-urlencoded"
1971 named http_error_DDD where DDD is the 3-digit error code."""
1989 def _https_connection(self, host): argument
1990 return http.client.HTTPSConnection(host,
2011 host, file = _splithost(url)
2021 'Content-Type: %s\nContent-Length: %d\nLast-modified: %s\n' %
2023 if not host:
2028 host, port = _splitport(host)
2030 and socket.gethostbyname(host) in ((localhost(),) + thishost())):
2037 raise URLError('local file error: not on local host')
2044 host, path = _splithost(url)
2045 if not host: raise URLError('ftp error: no host given')
2046 host, port = _splitport(host)
2047 user, host = _splituser(host)
2050 host = unquote(host)
2053 host = socket.gethostbyname(host)
2062 dirs, file = dirs[:-1], dirs[-1]
2065 key = user, host, port, '/'.join(dirs)
2077 ftpwrapper(user, passwd, host, port, dirs)
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)."""
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']
2271 host, selector = _splithost(url)
2272 newurl = 'http://' + host + selector
2289 host, selector = _splithost(url)
2290 newurl = 'https://' + host + selector
2307 host, selector = _splithost(url)
2308 i = host.find('@') + 1
2309 host = host[i:]
2310 user, passwd = self.get_user_passwd(host, realm, i)
2312 host = "%s:%s@%s" % (quote(user, safe=''),
2313 quote(passwd, safe=''), host)
2314 newurl = 'http://' + host + selector
2321 host, selector = _splithost(url)
2322 i = host.find('@') + 1
2323 host = host[i:]
2324 user, passwd = self.get_user_passwd(host, realm, i)
2326 host = "%s:%s@%s" % (quote(user, safe=''),
2327 quote(passwd, safe=''), host)
2328 newurl = 'https://' + host + selector
2334 def get_user_passwd(self, host, realm, clear_cache=0): argument
2335 key = realm + '@' + host.lower()
2341 user, passwd = self.prompt_user_passwd(host, realm)
2345 def prompt_user_passwd(self, host, realm): argument
2349 user = input("Enter username for %s at %s: " % (realm, host))
2351 (user, realm, host))
2370 """Return the IP addresses of the current host."""
2402 def __init__(self, user, passwd, host, port, dirs, timeout=None, argument
2406 self.host = host
2422 self.ftp.connect(self.host, self.port, self.timeout)
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)
2530 def proxy_bypass_environment(host, proxies=None): argument
2531 """Test if proxies should not be used for a particular host.
2547 host = host.lower()
2548 # strip port off host
2549 hostonly, port = _splitport(host)
2550 # check if the host ends with any of the DNS suffixes
2556 if hostonly == name or host == name:
2559 if hostonly.endswith(name) or host.endswith(name):
2567 def _proxy_bypass_macosx_sysconf(host, proxy_settings): argument
2569 Return True iff this host shouldn't be accessed using a proxy
2581 hostonly, port = _splitport(host)
2590 # Check for simple host names:
2591 if '.' not in host:
2621 mask = 32 - mask
2626 elif fnmatch(host, value):
2635 def proxy_bypass_macosx_sysconf(host): argument
2637 return _proxy_bypass_macosx_sysconf(host, proxy_settings)
2640 """Return a dictionary of scheme -> proxy server URL mappings.
2649 def proxy_bypass(host): argument
2650 """Return True, if host should be bypassed.
2658 return proxy_bypass_environment(host, proxies)
2660 return proxy_bypass_macosx_sysconf(host)
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.
2725 def proxy_bypass_registry(host): argument
2729 # Std modules, so should be around - but you never know!
2743 # try to make a host list from name and IP address.
2744 rawHost, port = _splitport(host)
2745 host = [rawHost]
2749 host.append(addr)
2755 host.append(fqdn)
2770 for val in host:
2775 def proxy_bypass(host): argument
2776 """Return True, if host should be bypassed.
2784 return proxy_bypass_environment(host, proxies)
2786 return proxy_bypass_registry(host)