Gets/sets the host.

@param  string      $host The host of the message
@return string|self
346427
public function host($host = null)
    {
        if (func_num_args() === 0) {
            $scheme = $this->_classes['scheme'];
            $port = $scheme::port($this->_scheme) !== $this->_port ? $this->_port : null;
            return ($port !== null ? "{$this->_host}:{$port}" : $this->_host);
        }
        if (strpos($host, ':')) {
            list($host, $port) = explode(':', $host);
            $this->port($port);
        }
        $this->_host = $host;
        $headers = $this->headers();
        $headers->prepend('Host', $this->host());
        return $this;
    }
318751
public final function withHost($host): UriInterface
   {
       if (!is_string($host) || !($parsedHost = $this->parseHost($host))) {
           throw new InvalidArgumentException(
               "Can't get with host: invalid host name");
       }
       return $this->with("host", $parsedHost);
   }
1039417
public static function serializeHost($host)
    {
        if (is_int($host) || is_float($host)) {
            $string = self::serializeIPv4($host);
        } elseif (is_array($host)) {
            $string = '[' . self::serializeIPv6($host) . ']';
        } else {
            $string = (string)$host;
        }
        return $string;
    }
411479
public function setHost($host)
    {
        if ($this->validateHost($host) === false) {
            throw new Zend_Uri_Exception("Host \"$host\" is not a valid HTTP host");
        }

        $oldHost     = $this->_host;
        $this->_host = $host;

        return $oldHost;
    }
536907
protected static function filterHost($host)
    {
        if (! is_string($host)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid host; must be a string argument; received %s',
                (is_object($host) ? get_class($host) : gettype($host))
            ));
        }

        return $host;
    }
1178696
public function setServer($host, $port = 0)
    {
        assert(is_string($host));
        if ($host[0] == '/') {
            $this->_path = 'unix://'.$host;

            return;
        }
        if (substr($host, 0, 7) == 'unix://') {
            $this->_path = $host;

            return;
        }

        $this->_host = $host;
        if (is_int($port)) {
            if ($port) {
                $this->_port = $port;
            }
        }
        $this->_path = '';

        return $this;
    }
936999
public function getReason($host)
    {
        $hostcdNode = $this->getHostcd($host);
        $node = $this->getFirst('host:reason', $hostcdNode);

        return $node === null ? null : $node->nodeValue;
    }
674334
private function getHostIfNull($host)
    {
        if ($host === null) {
            $host = $this->header->get('HOST');
        }

        if ($host === null) {
            $host = $this->server->get('SERVER_NAME');
        }

        if ($host === null) {
            // Return an empty string by default so we can do string operations on it later
            $host = $this->server->get('SERVER_ADDR', '');
        }

        return $host;
    }
569115
public function setHost($host)
    {
        if (substr($host, -1) === '/') {
            $host = substr($host, 0, strlen($host) - 1);
        }

        $this->host = $host;
    }
1271007
public function getHostBaseUrl($host = null)
    {
        $config = $this->getFullHost($host);

        return sprintf('%s://%s', $config['protocol'], $config['host']);
    }
1037093
public function assertHostIs($host)
    {
        $pattern = str_replace('\*', '.*', preg_quote($host, '/'));

        $actual = parse_url($this->driver->getCurrentURL(), PHP_URL_HOST) ?? '';

        PHPUnit::assertRegExp(
            '/^'.$pattern.'$/u', $actual,
            "Actual host [{$actual}] does not equal expected host [{$pattern}]."
        );

        return $this;
    }
340659
public function removeHost(string $host)
	{
		$host = Host::filter($host);
		if( $this->offsetExists($host) ) unset( $this->hosts[$host] );
		return $this;
	}
884727
public static function host($host)
    {
        if (!isset($_SERVER['HTTP_HOST'])) {
            return false;
        }
        $lower = \strtolower($_SERVER['HTTP_HOST']);

        if (\is_string($host)) {
            return $host === $lower;
        }

        if (\is_array($host)) {
            foreach ($host as $item) {
                if ($item === $lower) {
                    return true;
                }
            }
            return false;
        }
        return false;
    }
314867
private function filterHost(string $host): string
    {
        if ($host && $host !== self::HTTP_DEFAULT_HOST && strpos($host, '.') === false) {
            throw new InvalidArgumentException("Host '{$host}' is illegal!");
        }

        return strtolower($host);
    }
1345182
public static function setHost($host) {

		if(false === is_string($host)) {
  			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($host)), E_USER_ERROR);
  		}

		$_SERVER['HTTP_HOST'] = $host;
	}
241337
private function filterHost(string $host): string
    {
        return preg_replace_callback(
            '/(?:[^'.self::UNRESERVED.self::SUB_DELIMS.':%\[\]]+|%(?![A-Fa-f0-9]{2}))/',
            function (array $match) {
                return rawurlencode($match[0]);
            },
            $host
        );
    }
404924
public static function parse_host($host) {
		// Try to parse it the easy way.
		$tmp = v_mb::parse_url($host, \PHP_URL_HOST);
		if ($tmp) {
			$host = $tmp;
		}
		// Or the hard way?
		else {
			r_cast::string($host, true);

			r_mb::trim($host);

			// Cut off the path, if any.
			if (false !== ($start = v_mb::strpos($host, '/'))) {
				$host = v_mb::substr($host, 0, $start);
			}

			// Cut off the query, if any.
			if (false !== ($start = v_mb::strpos($host, '?'))) {
				$host = v_mb::substr($host, 0, $start);
			}

			// Cut off credentials, if any.
			if (false !== ($start = v_mb::strpos($host, '@'))) {
				$host = v_mb::substr($host, $start + 1, null);
			}

			// Is this an IPv6 address?
			if (\filter_var($host, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6)) {
				r_sanitize::ip($host, true);
			}
			elseif (
				(0 === \strpos($host, '[')) &&
				false !== ($end = v_mb::strpos($host, ']'))
			) {
				$host = v_mb::substr($host, 1, $end - 1);
				r_sanitize::ip($host, true);
			}
			// Cut off port, if any.
			elseif (false !== ($start = v_mb::strpos($host, ':'))) {
				$host = v_mb::substr($host, 0, $start);
			}

			// If it is empty or invalid, there is nothing we can do.
			if (! \strlen($host)) {
				return false;
			}

			// Convert to ASCII if possible.
			if (\function_exists('idn_to_ascii')) {
				$host = \explode('.', $host);
				r_file::idn_to_ascii($host);
				$host = \implode('.', $host);
			}

			// Lowercase it.
			r_mb::strtolower($host, false);

			// Get rid of trailing periods.
			$host = \ltrim($host, '.');
			$host = \rtrim($host, '.');
		}

		// Liberate IPv6 from its walls.
		if (0 === \strpos($host, '[')) {
			$host = \str_replace(array('[', ']'), '', $host);
			r_sanitize::ip($host, true);
		}

		// Is this an IP address? If so, we're done!
		if (\filter_var($host, \FILTER_VALIDATE_IP)) {
			return $host;
		}

		// Look for illegal characters. At this point we should
		// only have nice and safe ASCII.
		if (\preg_match('/[^a-z\d\-\.]/u', $host)) {
			return false;
		}
		$host = \explode('.', $host);
		foreach ($host as $v) {
			// Gotta have length, and can't start or end with a dash.
			if (
				! \strlen($v) ||
				(0 === \strpos($v, '-')) ||
				('-' === \substr($v, -1))
			) {
				return false;
			}
		}

		return \implode('.', $host);
	}