Retrieve HTTP HOST

@param bool $trimPort
@return string
329464
public function getHttpHost($trimPort = true) {
        if ( ! isset($this->SERVER['HTTP_HOST'])) {
            return false;
        }
        if ($trimPort) {
            $host = explode(':', $this->SERVER['HTTP_HOST']);
            return $host[0];
        }
        return $this->SERVER['HTTP_HOST'];
    }
815735
public function setHost($host)
    {
        $this->host = $host;
        if (strpos($host, '/') !== false || strpos($host, '?') !== false) {
            if (strpos($host, 'http') === false) {
                $host = 'https://' . $host;
            }
            $url = parse_url($host);
            $this->host = $url['host'];

            if (isset($url['path'])) {
                $this->setPath($url['path']);
            }

            if (isset($url['query'])) {
                if (!isset($url['path'])) { // for example.org?query=string
                    $this->setPath('/');
                }
                $this->setQuery($url['query']);
            }
        }

        return $this;
    }
1181800
public static function getHost($pPath = '', $pHost = '')
    {
        if (! $pHost) {
            $pHost = $_SERVER['HTTP_HOST'];
        }

        return self::getProtocol() . $pHost . $pPath;
    }
512171
public static function port(HTTPRequest $request = null)
    {
        $host = static::host($request);
        return (int)parse_url($host, PHP_URL_PORT) ?: null;
    }
856034
public function url($include_host = false)
    {
        if ($include_host) {
            return $this->url;
        }

        $url = str_replace($this->base, '', rtrim($this->url, '/'));

        return $url ?: '/';
    }
27473
public static function getHost() : string
  {
      // Check for proxy first
      $host = isset($_SERVER['HTTP_X_FORWARDED_HOST']) ?
          last(explode(',', $_SERVER['HTTP_X_FORWARDED_HOST'])) : 
          $_SERVER['HTTP_HOST'] ?? 
          $_SERVER['HTTP_SERVER_NAME'] ?? 
          $_SERVER['HTTP_SERVER_ADDR'];

      // trim and remove port number from host
      // host is lowercase as per RFC 952/2181
      return strtolower(preg_replace('/:\d+$/', '', trim($host)));
  }
848710
public static function getHostFromUrl($url)
    {
        $parsedUrl = parse_url($url);

        if (empty($parsedUrl['host'])) {
            return;
        }

        return Common::mb_strtolower($parsedUrl['host']);
    }
128712
public function getUrl($includeQueryString = true)
    {
        $url = $this->getProtocol() . '://';
        $url .= $this->getHostname();

        $isAbnormalPort = ($this->isHttps() && $this->getPort() != 443) || (!$this->isHttps() && $this->getPort() != 80);

        if ($isAbnormalPort) {
            $url .= ':' . $this->getPort();
        }

        $url .= $this->getRequestUri($includeQueryString);
        return $url;
    }
675200
public static function getHeaderFromUrl($url) {
		// @codingStandardsIgnoreStart
		$url = @parse_url($url);
		// @codingStandardsIgnoreEnd
		if (empty($url)) {
			return false;
		}

		$url = array_map('trim', $url);
		$url['port'] = (!isset($url['port'])) ? '' : (':' . (int)$url['port']);
		$path = (isset($url['path'])) ? $url['path'] : '';

		if (empty($path)) {
			$path = '/';
		}

		$path .= (isset($url['query'])) ? "?$url[query]" : '';

		$defaults = [
			'http' => [
				'header' => "Accept: text/html\r\n" .
					"Connection: Close\r\n" .
					"User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64)\r\n",
			]
		];
		stream_context_get_default($defaults);

		if (isset($url['host']) && $url['host'] !== gethostbyname($url['host'])) {
			$url = "$url[scheme]://$url[host]$url[port]$path";
			$headers = get_headers($url);
			if (is_array($headers)) {
				return $headers;
			}
		}
		return false;
	}
1356001
protected function _getShopHostInfoFromConfig()
    {
        $sShopURL = Registry::getConfig()->getConfigParam('sShopURL');
        if (preg_match('#^(https?://)?([^/:]+)(:([0-9]+))?(/.*)?$#i', $sShopURL, $m)) {
            $sHost = $m[2];
            $iPort = (int) $m[4];
            $blSsl = (strtolower($m[1]) == 'https://');
            if (!$iPort) {
                $iPort = $blSsl ? 443 : 80;
            }
            $sScript = rtrim($m[5], '/') . '/';

            return [
                'host' => $sHost,
                'port' => $iPort,
                'dir'  => $sScript,
                'ssl'  => $blSsl,
            ];
        }

        return false;
    }
657652
public static function getSelfHost()
    {
        $currentHost = self::getRawHost();

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

        return $currentHost;
    }
545272
private function getHostLength()
    {
        $hostLength = strpos($this->url, '/');
        $hostLength = (false === $hostLength) ? strlen($this->url) : $hostLength;

        return $hostLength;
    }
218854
public function HostAndPort() {
      $Host = $this->Host();
      $Port = $this->Port();
      if (!in_array($Port, array(80, 443)))
         return $Host.':'.$Port;
      else
         return $Host;
   }
1210170
public function getHostRoot($host)
    {
        $root_path = $this->httpRoot[$host]['root'] ?? '';
        if (empty($root_path)) {
            $root_path = $this->httpRoot['default']['root'] ?? '';
        }
        if (!empty($root_path)) {
            $root_path = WWW_DIR . "/$root_path/";
        } else {
            $root_path = WWW_DIR . "/";
        }
        return $root_path;
    }
1229915
public function getPort() : string
  {
      // Check for proxy first
      $port = self::server('HTTP_X_FORWARDED_PORT');
      if ($port) {
          return (string)$port;
      }

      $protocol = (string)self::server('HTTP_X_FORWARDED_PROTO');
      if ($protocol === 'https') {
          return '443';
      }

      return (string)self::server('SERVER_PORT');
  }
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;
    }
168497
public function getHost()
    {
        if ($this->isSandboxEnabled()) {
            $url = $this->getPayPalSandboxHost();
        } else {
            $url = $this->getPayPalHost();
        }

        return $url;
    }