Converts a well-formed URI containing a hostname and port into
string which allows for lookups in the Security Domain table
@param uri URI to convert
@return A string with "host:port" concatenated
@throws URISyntaxException
4057
public String formatKey(URI uri) throws URISyntaxException
	{
		if (uri == null) {
			throw new URISyntaxException("","URI specified is null");
		}
		return formatKey(uri.getHost(), uri.getPort());
	}
138226
public static URI getRequestURI(URI requestURI, String hostHeader, IoSession session) {
        boolean secure = SslUtils.isSecure(session);
        String authority = HttpUtils.getHostAndPort(hostHeader, secure);
        // Use getRawPath to get the un-decoded path; getPath returns the post-decode value.
        // This is required to handle special characters like spaces in the URI (KG-831).
        URI uri = URI.create("//" + authority + requestURI.getRawPath());
        return uri;
    }
875983
public Map<String, String> getUrlParams(URI uri) throws URIException {
		Map<String, String> map = new HashMap<>();
		for (NameValuePair parameter : getUrlParamParser(uri.toString()).parseParameters(uri.getEscapedQuery())) {
			String value = parameter.getValue();
			if (value == null) {
				value = "";
			}
			map.put(parameter.getName(), value);
		}
		return map;
	}
1347828
def host_from_uri(uri):
    
    default_ports = {
        'HTTP': '80',
        'HTTPS': '443',
    }

    sch, netloc, path, par, query, fra = urlparse(uri)
    if ':' in netloc:
        netloc, port = netloc.split(':', 1)
    else:
        port = default_ports.get(sch.upper())

    return netloc, port
757989
public static String getHost(String uriString) {
        try {
            URI uri = new URI(uriString);
            if(uri.getHost()==null) {
                throw new IllegalArgumentException("Invalid URI syntax. Scheme and host must be provided (port number is optional): " + uriString);
            }
            if (uri.getAuthority().startsWith("@") && !uri.getHost().startsWith("@")) {
                return "@" + uri.getHost();
            }
            return uri.getHost();
        }
        catch (URISyntaxException e) {
            try {
                return (new NetworkInterfaceURI(uriString)).getHost();
            }
            catch (IllegalArgumentException ne) {
                throw new IllegalArgumentException(ne.getMessage(), ne);
            }
        }
    }
1320794
public static String getResponseAsString(String uri, String charsetName) {
        return request(new HttpGet(uri), charsetName);
    }
413599
private URI checkURI(String uri)
  {
    try
    {
      return new URI(Preconditions.checkNotNull(uri).trim());
    } catch (URISyntaxException e)
    {
      parser.getReport().message(MessageId.RSC_020, parser.getLocation(), uri);
      return null;
    }
  }
711975
public static String normalize(final String uri) {
        String normalizedUri = null;
        if (uri != null) {
            normalizedUri = uri; // TODO THIS HAS TO BE IMPLEMENTED
        }
        return normalizedUri;
    }
1096844
public Socket getSocket(URI uri, boolean wantTLS) throws Exception
	{
		if (uri == null) {
			throw new URISyntaxException("", "The URI specified cannot be null");
		}
		
		// Get the registered security domain for the URI
		SecurityDomain securityDomain = null;
		if (wantTLS) {
			securityDomain = CONTEXT.getSecurityDomainManager().getSecurityDomain(uri);
		}
		return getSocket(uri,wantTLS,securityDomain);
	}
812661
public static String resourceName(URI uri) {
        if (!CLASSPATH_SCHEME.equals(uri.getScheme())) {
            throw new IllegalArgumentException("uri must have classpath scheme " + uri);
        }

        String resourceName = uri.getSchemeSpecificPart();
        if (resourceName.startsWith("/")) {
            return resourceName.substring(1);
        }
        return resourceName;
    }
191162
public static String modifyURIPort(String uri, int newPort) {
        try {
            URI uriObj = new URI(uri);
            return uriToString(URLUtils.modifyURIPort(uriObj, newPort));
        }
        catch (URISyntaxException e) {
            try {
                return (new NetworkInterfaceURI(uri)).modifyURIPort(newPort);
            }
            catch (IllegalArgumentException ne) {
                throw new IllegalArgumentException(ne.getMessage(), ne);
            }
        }
    }
1166251
public static InetAddress toInetAddress(URI uri) {
		try {
			// Copy/paste from the ZeroMQ lib
			final String protocol = uri.getScheme();
			final String address = uri.getHost();
			if ("tcp".equalsIgnoreCase(protocol)) { //$NON-NLS-1$
				return InetAddress.getByName(address);
			}
			throw new IllegalArgumentException(uri.toString());
		} catch (UnknownHostException e) {
			throw new IOError(e);
		}
	}
555573
public static String normalizeURI( String uri )
    {
        //
        // If it's a relative URI, normalize it.  Note that we don't want to create a URI
        // (very expensive) unless we think we'll need to.  "./" catches "../" and "./".
        //
        if ( uri.indexOf( "./" ) != -1 )
        {
            try
            {
                uri = new URI( uri ).normalize().toString();
            }
            catch ( URISyntaxException e )
            {
                logger.error( "Could not parse relative URI " + uri );
            }
        }
        
        return uri;
    }
864464
public static String getHost(URI uri) throws IOException {
    String host = uri.getHost();
    if (host != null) {
      return host;
    }
    host = uri.toString();
    int sInd = host.indexOf("//") + 2;
    host = host.substring(sInd);
    int eInd = host.indexOf("/");
    if (eInd != -1) {
      host = host.substring(0,eInd);
    }
    host = URLDecoder.decode(host, StandardCharsets.UTF_8.toString());
    return host;
  }
426996
public static String shortenUrl( URI uri )
    {
        return uri.getScheme() + "://" + uri.getHost() + uri.getPath();
    }
266477
public static String convertHostToPunycode(String uriString) {

        if (uriString.indexOf(":") >= 0) {
            try {
                URI uri = new URI(uriString);
                String authority = uri.getAuthority(); // getHost won't work when we have special characters
                int colonPos = authority.indexOf(':');
                if (colonPos >= 0) {
                    authority = IDN.toASCII(authority.substring(0, colonPos)) + authority.substring(colonPos);
                } else {
                    authority = IDN.toASCII(authority);
                }
                URI uriWithCorrectedHost = new URI(
                    uri.getScheme(),
                    authority,
                    uri.getPath(),
                    uri.getQuery(),
                    uri.getFragment());
                uriString = uriWithCorrectedHost.toASCIIString();
            } catch (URISyntaxException e) {
                LOG.error(e.getLocalizedMessage(), e);
            }
        }
        return uriString;
    }
466438
private String sanitizeUri(String uri) {
        if (uri == null || uri.length() == 0) {
            return null;
        }
        try {
            return new URI(uri).toString();
        } catch (URISyntaxException e) {
            return null;
        }
    }