Convert Cookies to (k=v; k=v) key-value pair string for Request

@param string $uri

@return string
486768
public function toRequestString(string $uri = ''): string
    {
        return !empty($this->raw) ? self::kvToRequestString($this->toRequestArray($uri)) : '';
    }
1009622
protected function _normalizedUrl($uri)
    {
        $out = $uri->getScheme() . '://';
        $out .= strtolower($uri->getHost());
        $out .= $uri->getPath();

        return $out;
    }
958741
protected function extractOptionalParameters($uri)
    {
        preg_match_all('/\{(\w+?)\?\}/', $uri, $matches);

        return isset($matches[1]) ? array_fill_keys($matches[1], null) : array();
    }
284519
protected function processUri($uri)
    {
        return preg_replace_callback('#\{([a-zA-Z0-9_,]*)\}#i', function ($matches) {
            return isset($this->tokens[$matches[1]]) ? $this->tokens[$matches[1]] : '';
        }, $uri);
    }
531347
private function buildKeyUri($key)
    {
        if (strpos($key, '/') !== 0) {
            $key = '/' . $key;
        }
        $uri = '/' . $this->apiversion . '/keys' . $this->root . $key;
        return $uri;
    }
300133
public function parseUri($uri)
    {
        $ret = [];
        foreach (explode($this->seperators['param'], $uri) as $params) {
            if ($params) {
                @list($key, $values) = explode($this->seperators['key_value'], $params, 2);
                $external = $key;
                if ($internal = $this->translateKeyInput($key)) {
                    $key = $internal;
                }
                $ret[$key] = [];
                foreach (explode($this->seperators['value'], $values) as $value) {
                    if (strlen($value) > 0) {
                        if ($internal = $this->translateValueInput($external, $value)) {
                            $value = $internal;
                        }
                        $ret[$key][] = urldecode($value);
                    }
                }
            }
        }

        return $ret;
    }
1311594
private function getPathFromUri($uri)
    {
        $uriParser = new UriParser($uri);
        // Prepare uri
        $uriParser->encode();
        $uri = $uriParser->stripFragment();
        if (strpos($uri, '/') === 0) {
            // URI is already an path
            return $uri;
        }
        if (!$uriParser->validate()) {
            throw new \InvalidArgumentException('Invalid URI');
        }
        $path = (($path = parse_url($uri, PHP_URL_PATH)) === null) ? '/' : $path;
        $query = (($query = parse_url($uri, PHP_URL_QUERY)) === null) ? '' : '?' . $query;
        return $path . $query;
    }
246271
private static String convertV1Cookie(HttpCookie cookie) {
        StringBuilder buffer = new StringBuilder(40);

        // Append name=value
        buffer.append(cookie.getName());
        buffer.append('=');
        maybeQuote(buffer, cookie.getValue());

        // Always append the version
        buffer.append("; $Version=1");

        // check for optional path
        String value = cookie.getPath();
        if (null != value && 0 != value.length()) {
            buffer.append("; $Path=");
            if (!skipCookiePathQuotes) {
                maybeQuote(buffer, value);
            } else {
                buffer.append(value);
            }
        }

        // check for optional domain
        value = cookie.getDomain();
        if (null != value && 0 != value.length()) {
            buffer.append("; $Domain=");
            maybeQuote(buffer, value);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Created v1 Cookie: [" + buffer.toString() + "]");
        }
        return buffer.toString();
    }
1021258
public function resolveRelativeUri(string $uri): string
    {
        $parts = parse_url($uri);
        if (isset($parts['scheme'])) {
            // absolute URL
            return $uri;
        }

        $baseUri = $this->getUri();
        if (strncmp($baseUri, 'file://', 7) === 0) {
            if (isset($parts['path'][0]) && $parts['path'][0] === '/') {
                // absolute path
                return 'file://' . $parts['path'];
            }
            if (isset($parts['path'])) {
                // relative path
                return dirname($baseUri) . '/' . $parts['path'];
            }

            throw new UnresolvableReferenceException("Invalid URI: '$uri'");
        }

        $baseParts = parse_url($baseUri);
        $absoluteUri = implode('', [
            $baseParts['scheme'],
            '://',
            isset($baseParts['username']) ? $baseParts['username'] . (
                isset($baseParts['password']) ? ':' . $baseParts['password'] : ''
            ) . '@' : '',
            $baseParts['host'] ?? '',
            isset($baseParts['port']) ? ':' . $baseParts['port'] : '',
        ]);
        if (isset($parts['path'][0]) && $parts['path'][0] === '/') {
            $absoluteUri .= $parts['path'];
        } elseif (isset($parts['path'])) {
            $absoluteUri .= rtrim(dirname($baseParts['path'] ?? ''), '/') . '/' . $parts['path'];
        }
        return $absoluteUri
            . (isset($parts['query']) ? '?' . $parts['query'] : '')
            . (isset($parts['fragment']) ? '#' . $parts['fragment'] : '');
    }
527809
protected function formatUri($uri): string
    {
        $scheme = $uri->getScheme();
        if ('' != $scheme) {
            $scheme = $scheme.':';
        }

        $authority = null;
        $host = $uri->getHost();
        if ('' != $host) {
            $user_info = $uri->getUserInfo();
            if ('' != $user_info) {
                $authority .= (new UserInfo())->withContent($user_info)->getContent($this->enc_type).'@';
            }
            $authority .= (new Host($host))->getContent($this->enc_type);
            $port = $uri->getPort();
            if (null !== $port) {
                $authority .= ':'.$port;
            }
        }

        if (null !== $authority) {
            $authority = '//'.$authority;
        }

        $path = (new Path($uri->getPath()))->getContent($this->enc_type);
        if (null !== $authority && '' !== $path && '/' !== $path[0]) {
            $path = '/'.$path;
        }

        $query = $uri->getQuery();
        if ('' != $query || $this->preserve_query) {
            $query = '?'.Uri\build_query(Uri\parse_query($query), $this->query_separator, $this->enc_type);
        }

        $fragment = $uri->getFragment();
        if ('' != $fragment || $this->preserve_fragment) {
            $fragment = '#'.(new Fragment($fragment))->getContent($this->enc_type);
        }

        return $scheme.$authority.$path.$query.$fragment;
    }
314284
protected function fromString($uri)
    {
        if (empty($uri)) {
            return $this;
        }

        $this->fromArray(parse_url($uri));

        return $this;
    }
1215218
public static function encodeUri($uri)
    {
        $uri = self::removeSchemeFromUri($uri, $scheme);
        $uri = rawurlencode($uri);

        // Decode slashes
        $uri = str_replace("%2F", "/", $uri);

        return $scheme . $uri;
    }
893120
public function stripRefreshTokenValue(string $uri): string
    {

        // If we have 'refresh_token' in the URI, strip it.
        if (strpos($uri, 'refresh_token'))
            return Uri::withoutQueryValue((new Uri($uri)), 'refresh_token')
                ->__toString();

        return $uri;
    }
749570
protected function chopIndex($uri)
    {
        $subStr = strtolower(substr($uri,0, 10));
        if ("/index.php" == $subStr) {
            return (strlen($uri) > 10 ? substr($uri, 10) : '');
        }

        return $uri;
    }
1022342
public function cookieDomain(UriInterface $uri): ?string
    {
        $host = $uri->getHost();
        if (empty($host)) {
            return null;
        }

        $pattern = $this->config['cookies']['domain'];
        if (preg_match("/^(\d{1,3}){4}:\d+$/", $host, $matches)) {
            // remove port
            $host = $matches[1];
        }

        if (filter_var($host, FILTER_VALIDATE_IP) || $host == 'localhost') {
            //We can't use sub-domains when website required by IP
            $pattern = ltrim($pattern, '.');
        }

        if (strpos($pattern, '%s') === false) {
            //Forced domain
            return $pattern;
        }

        return sprintf($pattern, $host);
    }
204481
public function uri_to_qname($uri) {
        if (preg_match('~^(.*[\/\#])([a-z0-9\-\_\:]+)$~i', $uri, $m)) {
            $ns = $m[1];
            $localname = $m[2];
            $prefix = $this->get_prefix($ns);
            if ( $prefix != null && $prefix !== FALSE) {
                return $prefix . ':' . $localname;
            }
        }
        return null;
    }
1339892
private function translate_uri($uri) {
        // remove all html entities...
        $native_path = html_entity_decode($uri);
        $parts = explode('/', $native_path);
        for ($i = 0; $i < count($parts); $i++) {
            // check if part is allready utf8
            if (iconv('UTF-8', 'UTF-8', $parts[$i]) == $parts[$i]) {
                $parts[$i] = rawurlencode($parts[$i]);
            } else {
                $parts[$i] = rawurlencode(utf8_encode($parts[$i]));
            }
        }
        return implode('/', $parts);
    }