Reconstruct host from environment. A modified version
    of http://www.python.org/dev/peps/pep-0333/#url-reconstruction
768252
def host(environ):  # pragma: no cover
    

    url = environ['wsgi.url_scheme'] + '://'

    if environ.get('HTTP_HOST'):
        url += environ['HTTP_HOST']
    else:
        url += environ['SERVER_NAME']

        if environ['wsgi.url_scheme'] == 'https':
            if environ['SERVER_PORT'] != '443':
                url += ':' + environ['SERVER_PORT']
        else:
            if environ['SERVER_PORT'] != '80':
                url += ':' + environ['SERVER_PORT']

    return url + quote(environ.get('SCRIPT_NAME', ''))
302142
def parse_host(self, tup_tree):
        

        self.check_node(tup_tree, 'HOST', (), (), (), allow_pcdata=True)

        return self.pcdata(tup_tree)
160623
def unescape(url):
    '''
    
    '''
    scheme = urlparse(url).scheme
    if not scheme:
        return url.lstrip('|')
    elif scheme == 'salt':
        path, saltenv = parse(url)
        if salt.utils.platform.is_windows() and '|' in url:
            return create(path.lstrip('_'), saltenv)
        else:
            return create(path.lstrip('|'), saltenv)
    else:
        return url
318272
def reconstruct(self):
        
        volumes = list(sorted((v for v in self.get_volumes() if v.mountpoint and v.info.get('lastmountpoint')),
                              key=lambda v: v.numeric_index))

        try:
            root = list(filter(lambda x: x.info.get('lastmountpoint') == '/', volumes))[0]
        except IndexError:
            logger.error("Could not find / while reconstructing, aborting!")
            raise NoRootFoundError()

        volumes.remove(root)

        for v in volumes:
            if v.info.get('lastmountpoint') == root.info.get('lastmountpoint'):
                logger.debug("Skipping volume %s as it has the same root as %s", v, root)
                continue
            v.bindmount(os.path.join(root.mountpoint, v.info.get('lastmountpoint')[1:]))
        return root
469499
def url_host(url: str) -> str:
    
    from urllib.parse import urlparse
    res = urlparse(url)
    return res.netloc.split(':')[0] if res.netloc else ''
834979
def get_host(url):
    
    # This code is actually similar to urlparse.urlsplit, but much
    # simplified for our needs.
    port = None
    scheme = 'http'
    if '//' in url:
        scheme, url = url.split('://', 1)
    if '/' in url:
        url, _path = url.split('/', 1)
    if ':' in url:
        url, port = url.split(':', 1)
        port = int(port)
    return scheme, url, port
153815
def request_host(request):
    
    url = request.get_full_url()
    host = urlparse(url)[1]
    if host == "":
        host = request.get_header("Host", "")

    # remove port, if present
    host = cut_port_re.sub("", host, 1)
    return host.lower()
922313
def get_host(environ):
    
    scheme = environ.get('wsgi.url_scheme')
    if 'HTTP_X_FORWARDED_HOST' in environ:
        result = environ['HTTP_X_FORWARDED_HOST']
    elif 'HTTP_HOST' in environ:
        result = environ['HTTP_HOST']
    else:
        result = environ['SERVER_NAME']
        if (scheme, str(environ['SERVER_PORT'])) not \
           in (('https', '443'), ('http', '80')):
            result += ':' + environ['SERVER_PORT']
    if result.endswith(':80') and scheme == 'http':
        result = result[:-3]
    elif result.endswith(':443') and scheme == 'https':
        result = result[:-4]
    return result
232683
def with_host(self, host):
        
        # N.B. doesn't cleanup query/fragment
        if not isinstance(host, str):
            raise TypeError("Invalid host type")
        if not self.is_absolute():
            raise ValueError("host replacement is not allowed " "for relative URLs")
        if not host:
            raise ValueError("host removing is not allowed")
        host = self._encode_host(host)
        val = self._val
        return URL(
            self._val._replace(
                netloc=self._make_netloc(
                    val.username, val.password, host, val.port, encode=False
                )
            ),
            encoded=True,
        )
24742
def _ipv6_host(host):
    

    # httplib doesn't like it when we include brackets in IPv6 addresses
    # Specifically, if we include brackets but also pass the port then
    # httplib crazily doubles up the square brackets on the Host header.
    # Instead, we need to make sure we never pass ``None`` as the port.
    # However, for backward compatibility reasons we can't actually
    # *assert* that.  See http://bugs.python.org/issue28539
    #
    # Also if an IPv6 address literal has a zone identifier, the
    # percent sign might be URIencoded, convert it back into ASCII
    if host.startswith('[') and host.endswith(']'):
        host = host.replace('%25', '%').strip('[]')
    return host
1367714
def map2hosts (hostmap):
    
    ret = hostmap[0].copy()
    for net, mask in hostmap[1]:
        ret.add("%s/%d" % (num2dq(net), mask2netmask(mask)))
    return ret
17464
function ___GET_ENV_HOSTNAME() {
	try {
		if ( HAS_NODE_BUFFER ) {
			return require( 'os' ).hostname;
		}
		else
		if ( typeof window !== "undefined" ) {
			return window.location.hostname;
		}
		else {
			throw new Error("");
		}
	}
	catch(e) {
		return 'unknown.' + DumpHexStringLE(RandomBytes(32));
	}
}
276244
def from_hostname(cls, hostname):
        """"""
        result = cls.list({'items_per_page': 500})
        paas_hosts = {}
        for host in result:
            paas_hosts[host['name']] = host['id']

        return paas_hosts.get(hostname)
1353072
def get_host(url):
    
    p = parse_url(url)
    return p.scheme or 'http', p.hostname, p.port
1107826
def get_host(self, use_x_forwarded=True):
        """"""
        # We try three options, in order of decreasing preference.
        if use_x_forwarded and ('HTTP_X_FORWARDED_HOST' in self.environ):
            host = self.environ['HTTP_X_FORWARDED_HOST']
            port = self.environ.get('HTTP_X_FORWARDED_PORT')
            if port and port != ('443' if self.is_secure else '80'):
                host = '%s:%s' % (host, port)
            return host
        elif 'HTTP_HOST' in self.environ:
            host = self.environ['HTTP_HOST']
        else:
            # Reconstruct the host using the algorithm from PEP 333.
            host = self.environ['SERVER_NAME']
            server_port = str(self.environ['SERVER_PORT'])
            if server_port != ('443' if self.is_secure else '80'):
                host = '%s:%s' % (host, server_port)
        return host
1220392
def get_url(self, environ):
        """"""
        if self.override_url:
            url = self.override_url
        else:
            # PEP333: wsgi.url_scheme, HTTP_HOST, SERVER_NAME, and SERVER_PORT
            # can be used to reconstruct a request's complete URL

            # Much of the following is copied from bottle.py
            http = (environ.get('HTTP_X_FORWARDED_PROTO') or
                    environ.get('wsgi.url_scheme', 'http'))
            host = (environ.get('HTTP_X_FORWARDED_HOST') or
                    environ.get('HTTP_HOST'))
            if not host:
                # HTTP 1.1 requires a Host-header. This is for HTTP/1.0
                # clients.
                host = environ.get('SERVER_NAME', '127.0.0.1')
                port = environ.get('SERVER_PORT')
                if port and port != ('80' if http == 'http' else '443'):
                    host += ':' + port
            url = "%s://%s" % (http, host)
        return url
450543
def get_host(name=None, ipv4addr=None, mac=None, return_fields=None, **api_opts):
    '''
    
    '''
    infoblox = _get_infoblox(**api_opts)
    host = infoblox.get_host(name=name, mac=mac, ipv4addr=ipv4addr, return_fields=return_fields)
    return host