parse the url and get the host and port string.

@return the host:port string
189870
private String hostAndPort() {
        int start = url.indexOf("://") + 3;
        int end = url.indexOf("/", start);
        return url.substring(start, end);
    }
137347
public static UrlBuilder parse(String url) {
        final UrlBuilder result = new UrlBuilder();
        result.with(url, UrlTokenizerState.SCHEME_OR_HOST);
        return result;
    }
1027496
public HttpHost getProxy() {
        String host = Config.getProperty(Config.PROXY_HOST);
        String port = Config.getProperty(Config.PROXY_PORT);
        HttpHost proxy = null;
        if (StringUtils.hasText(host) && StringUtils.hasText(port)) {
            proxy = new HttpHost(host, Integer.parseInt(port));
        }
        return proxy;
    }
1005800
private String getTargetHost() {
        String host = getVirtualHost();
        if (null == host) {
            host = (isIncoming()) ? getServiceContext().getLocalAddr().getCanonicalHostName() : getServiceContext().getRemoteAddr().getCanonicalHostName();
        }
        return host;
    }
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);
            }
        }
    }
1343002
def request_host(request):
    
    url = request.get_full_url()
    parse_result = compat.urlparse.urlparse(url)
    scheme, host, port = parse_result.scheme, parse_result.hostname, parse_result.port
    try:
        port = int(port)
    except ValueError:
        pass
    if host == "":
        host = request.get_header("Host", "")

    if port != default_ports.get(scheme):
        host = "%s:%s" % (host, port)
    return host
657652
public static function getSelfHost()
    {
        $currentHost = self::getRawHost();

        // strip the port
        if (false !== strpos($currentHost, ':')) {
            list($currentHost, $port) = explode(':', $currentHost, 2);
        }

        return $currentHost;
    }
49934
public static String parseHostFromHostAndPort(String hostAndPort) {
        return hostAndPort.lastIndexOf(':') > 0 ? hostAndPort.substring(0, hostAndPort.lastIndexOf(':')) : hostAndPort;
    }
1148623
@Override
	public String getMessage() {
		if (getCause() instanceof UnknownHostException) {
			return "Host (" + getHost() + ") is unreachable !!!!";
		}
		if (getCause() instanceof ConnectException) {
			return "Host (" + getHost() + ") is unreachable at Port (" + getPort() + ")!!!!";
		}
		return getCause().getMessage();
	}
1156131
public synchronized final String getHost() {
        if (host == null) {
            if (getEndpointAddress() != null && 
                    !getEndpointAddress().isUnresolved()) {
                host = getEndpointAddress().getHostName();
            }

            if (host == null && httpURI != null) {
                try {
                    host = (new URL(httpURI)).getHost();
                } catch (MalformedURLException e) {
                    logger.debug("Malformed URL", e);
                }
            }
        }

        return host;
    }
1120883
public int getPort()
    {
        if (_port > 0) return _port;
        if (_host != null) return 0;
        if (_uri.isAbsolute())
            _port = _uri.getPort();
        else if (_connection != null) _port = _connection.getServerPort();
        return _port;
    }
532220
public int getServerPort()
  {
    String host = null;

    CharSequence rawHost;
    if ((rawHost = getHost()) != null) {
      int length = rawHost.length();
      int i;

      for (i = length - 1; i >= 0; i--) {
        if (rawHost.charAt(i) == ':') {
          int port = 0;

          for (i++; i < length; i++) {
            char ch = rawHost.charAt(i);

            if ('0' <= ch && ch <= '9') {
              port = 10 * port + ch - '0';
            }
          }

          return port;
        }
      }

      // server/0521 vs server/052o
      // because of proxies, need to use the host header,
      // not the actual port
      return isSecure() ? 443 : 80;
    }

    if (host == null) {
      return connTcp().portLocal();
    }

    int p1 = host.lastIndexOf(':');

    if (p1 < 0)
      return isSecure() ? 443 : 80;
    else {
      int length = host.length();
      int port = 0;

      for (int i = p1 + 1; i < length; i++) {
        char ch = host.charAt(i);

        if ('0' <= ch && ch <= '9') {
          port = 10 * port + ch - '0';
        }
      }

      return port;
    }
  }
806905
def parse_url(self):
        
        self.scheme = None
        self.resource = None
        self.host = None
        self.port = None

        if self.url is None:
            return

        scheme, url = self.url.split(":", 1)
        parsed = urlsplit(url, scheme="http")
        if parsed.hostname:
            self.host = parsed.hostname
        elif '+unix' in scheme:
            self.host = 'localhost'
        else:
            raise ValueError("Invalid hostname from: %s", self.url)

        if parsed.port:
            self.port = parsed.port

        if scheme == "ws":
            if not self.port:
                self.port = 8080
        elif scheme == "wss":
            if not self.port:
                self.port = 443
        elif scheme in ('ws+unix', 'wss+unix'):
            pass
        else:
            raise ValueError("Invalid scheme: %s" % scheme)

        if parsed.path:
            resource = parsed.path
        else:
            resource = "/"

        if '+unix' in scheme:
            self.unix_socket_path = resource
            resource = '/'

        if parsed.query:
            resource += "?" + parsed.query

        self.scheme = scheme
        self.resource = resource
99552
public int getPort() {
    if (port != null && port != 0) {
      return port;
    }
    return urlParser != null ? urlParser.getHostAddresses().get(0).port : 3306;
  }
603731
public String getUrl(){
		final StringBuilder sb = new StringBuilder();
		sb.append("http://");
		sb.append(getHttpConfiguration().getBindHost().get());
		sb.append(":");
		sb.append(getHttpConfiguration().getPort());
		
		return sb.toString();
	}
406925
function getHost()
    {
        if ($this->host)
            return $this->host;
        
        // attempt to get host from target uri
        $host  = $this->getTarget();
        $host  = parse_url($host, PHP_URL_HOST);
        if (!$host && $this->headers()->has('Host')) {
            /** @var iHeader $host */
            $host = $this->headers()->get('Host');
            $host = $host->renderValueLine();
        }

        return $host;
    }
894625
def url(self):
		
		return urlparse.urlunparse((self.scheme, self.host, self.path, None, None, None))