Convert the URI host part to its ascii value.


@return Psr7UriInterface|UriInterface
437845
public static function hostToAscii($uri)
    {
        return $uri->withHost((string) (new Host(self::filterUri($uri)->getHost())));
    }
939148
private function uriTrim() {
		$uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
		$uri = trim($uri, '/\^$');
		if(strpos($uri,'?')) $uri = substr($uri,0,strpos($uri,'?'));
		return $uri;
	}
705903
public function toString ()
	{
		$content = "<VirtualHost {$this->address}:{$this->port}>" . PHP_EOL;
		
		foreach ($this->directives as $directive) {
			$content .= $directive->toString() . PHP_EOL;
		}
		
		$content .= PHP_EOL;
		
		foreach ($this->directories as $directory) {
			$content .= $directory->toString() . PHP_EOL;
		}
		$content .= PHP_EOL;
		
		$content .= "</VirtualHost>";
		
		return $content;
	}
360126
public function generateSigninInput()
    {
        $base64payload = $this->encoder->encode(json_encode($this->getPayload(), JSON_UNESCAPED_SLASHES));
        $base64header = $this->encoder->encode(json_encode($this->getHeader(), JSON_UNESCAPED_SLASHES));

        return sprintf('%s.%s', $base64header, $base64payload);
    }
476278
public static function getFullUri() {
		if(!isset($_GET['dachi_uri']))
			$_GET['dachi_uri'] = "";

		if(self::$uri === array() && isset($_GET['dachi_uri']))
			self::$uri = explode("/", trim($_GET['dachi_uri'], " \t\n\r\0\x0B/"));

		return self::$uri;
	}
139034
private function changeHostFromUri()
    {
        $host = $this->uri->getHost();

        if ($host === '') {
            return;
        }

        if (($port = $this->uri->getPort()) !== null) {
            $host .= ':' . $port;
        }

        $this->headers['Host'] = [$host];

        $this->rearrangeHostHeaderKey();
    }
1197553
private function abridgeUri($uri)
    {
        $i = 30;
        $j = 12;

        if (mb_strlen($uri) <= $i) {
            return $uri;
        }

        $host = rtrim(parse_url($uri, PHP_URL_HOST), '/');
        $path = '/'.ltrim(parse_url($uri, PHP_URL_PATH), '/');

        if ($host === getenv('HTTP_HOST')) {
            $i = 50;
            $j = 22;

            $host = '';
        } else {
            if (mb_strlen($host) > $i && mb_strlen($path) > $i) {
                return $this->abridgeStr($uri, 50, 22);
            }

            $host = $this->abridgeStr($host, 20, 7);
        }

        $path = $this->abridgeStr($path, $i, $j);

        return $host.$path;
    }
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;
    }
493019
public function getUri()
    {
        if ($this->valid() === false) {
            require_once 'Zend/Uri/Exception.php';
            throw new Zend_Uri_Exception('One or more parts of the URI are invalid');
        }

        $password = strlen($this->_password) > 0 ? ":$this->_password" : '';
        $auth     = strlen($this->_username) > 0 ? "$this->_username$password@" : '';
        $port     = strlen($this->_port) > 0 ? ":$this->_port" : '';
        $query    = strlen($this->_query) > 0 ? "?$this->_query" : '';
        $fragment = strlen($this->_fragment) > 0 ? "#$this->_fragment" : '';

        return $this->_scheme
             . '://'
             . $auth
             . $this->_host
             . $port
             . $this->_path
             . $query
             . $fragment;
    }
734036
public static function getUri() {
        if (self::$_uri === null) {
            $uri = explode('?', $_SERVER['REQUEST_URI'], 2)[0];
            self::$_uri = self::fixUri(substr($uri, strlen(BASE_URI)));
        }
        return self::$_uri;
    }
958401
public function toAscii()
    {
        if (0 === \preg_match('#[\x80-\xff]#', $this->_string)) {
            return $this;
        }

        $this->_string = Strings::toAscii($this->_string);

        return $this;
    }
1325316
public function getFileSourceMediaId(): \Psr\Http\Message\UriInterface
    {
        if (!$this->fileSourceMediaId) {
            return new Uri();
        }

        return $this->fileSourceMediaId;
    }
844094
def normalized_host
      return nil unless self.host
      @normalized_host ||= begin
        if !self.host.strip.empty?
          result = ::Addressable::IDNA.to_ascii(
            URI.unencode_component(self.host.strip.downcase)
          )
          if result =~ /[^\.]\.$/
            # Single trailing dots are unnecessary.
            result = result[0...-1]
          end
          result = Addressable::URI.normalize_component(
            result,
            CharacterClasses::HOST)
          result
        else
          EMPTY_STR.dup
        end
      end
      # All normalized values should be UTF-8
      @normalized_host.force_encoding(Encoding::UTF_8) if @normalized_host
      @normalized_host
    end
1088660
public static function getOrigin() {
		$headers = getallheaders ();
		if (isset ( $headers ['Origin'] )) {
			return $headers ['Origin'];
		}
		if (isset ( $_SERVER ['HTTP_ORIGIN'] )) {
			return $_SERVER ['HTTP_ORIGIN'];
		} else if (isset ( $_SERVER ['HTTP_REFERER'] )) {
			return $_SERVER ['HTTP_REFERER'];
		} else {
			return $_SERVER ['REMOTE_ADDR'];
		}
	}
1198757
public function readUri()
    {
        try {
            return $this->readString();
        } catch (BinaryStreamAccessException $e) {
            $msg = "An error occured while reading a URI.";
            throw new QtiBinaryStreamAccessException($msg, $this, QtiBinaryStreamAccessException::URI, $e);
        }
    }
1374396
static public function escapeUri(string $uri): string {
        self::initSerializer();
        return self::$serializer->serialiseValue(new Resource($uri));
    }
801836
public function getUri($as_string = false)
    {
        if ($as_string && $this->uri instanceof Zend_Uri_Http) {
            return $this->uri->__toString();
        } else {
            return $this->uri;
        }
    }