Create an UriInterface with the host information from `$server`. It uses `$server['HTTP_HOST']` or
`$server['SERVER_NAME']` for this information.

@param UriInterface $uri
@param array        $server

@return UriInterface
496439
private function withHost(UriInterface $uri, array $server) : UriInterface {
		if (isset($server['HTTP_HOST'])) {
			$server['HTTP_HOST'] = preg_replace('/:[0-9]+$/', '', $server['HTTP_HOST']);
			return $uri->withHost($server['HTTP_HOST']);
		} elseif (isset($server['SERVER_NAME'])) {
			return $uri->withHost($server['SERVER_NAME']);
		}

		return $uri;
	}
1271029
public static function create(array $server = null)
    {
        $server = $server ?: $_SERVER;
        $agent = $server['HTTP_USER_AGENT'] ?? null;

        return new static(new Browser($agent, $server), new Platform($server));
    }
1087473
public function load(UriInterface $uri)
    {
        if (!$uri instanceof FileUriInterface) {
            throw new InvalidUriTypeException(
                $uri,
                'Eloquent\Schemer\Uri\FileUriInterface'
            );
        }

        $path = $this->pathFromUri($uri);

        try {
            $data = $this->isolator->file_get_contents($path);
        } catch (ErrorException $e) {
            throw new LoadException($uri, $e);
        }

        return new Content($data, $this->extensionMap()->getByPath($path));
    }
54427
private function addPortToUri(UriInterface $uri): UriInterface
    {
        $requestPort = $this->request->getUri()->getPort();

        if (!in_array($requestPort, [80, 443])) {
            $uri = $uri->withPort($requestPort);
        }

        return $uri;
    }
946521
public function getUrl(): \Psr\Http\Message\UriInterface
    {
        if (!$this->url) {
            return new Uri();
        }

        return $this->url;
    }
806348
public static function make(array $server = null)
    {
        if (empty($server)) {
            $server = $_SERVER;
        }

        if (isset($server['SERVER_PROTOCOL'])) {
            return $server['SERVER_PROTOCOL'];
        }

        return 'HTTP/1.1';
    }
847482
public static function make(array $server = null)
    {
        if (empty($server)) {
            $server = $_SERVER;
        }
        $headers = [];
        $content = [
            'CONTENT_TYPE'   => 'Content-Type',
            'CONTENT_LENGTH' => 'Content-Length',
            'CONTENT_MD5'    => 'Content-Md5',
        ];
        foreach ($server as $key => $value) {
            if (substr($key, 0, 5) === 'HTTP_') {
                $key = substr($key, 5);
                if (! isset($content[$key]) || ! isset($server[$key])) {
                    $key = str_replace('_', ' ', $key);
                    $key = ucwords(strtolower($key));
                    $key = str_replace(' ', '-', $key);

                    $headers[$key] = $value;
                }
            } elseif (isset($content[$key])) {
                $headers[$content[$key]] = $value;
            }
        }

        return $headers;
    }
418394
public function withUri(UriInterface $uri, $preserveHost = false)
    {
        $new = self::create($uri);
        if ($preserveHost) {
            $new->headers->set('HOST', $this->getHost());
        }

        return $new;
    }
458855
public static function getUriFromGlobals(array $serverParams): UriInterface
    {
        $uri = new Uri('');

        $uri = $uri->withScheme(isset($serverParams['HTTPS']) && $serverParams['HTTPS'] !== 'off' ? 'https' : 'http');

        $hasPort = false;
        if (isset($serverParams['HTTP_HOST'])) {
            $hostHeaderParts = explode(':', $serverParams['HTTP_HOST'], 2);
            $uri = $uri->withHost($hostHeaderParts[0]);
            if (count($hostHeaderParts) > 1) {
                $hasPort = true;
                $uri = $uri->withPort((int) $hostHeaderParts[1]);
            }
        } elseif (isset($serverParams['SERVER_NAME'])) {
            $uri = $uri->withHost($serverParams['SERVER_NAME']);
        } elseif (isset($serverParams['SERVER_ADDR'])) {
            $uri = $uri->withHost($serverParams['SERVER_ADDR']);
        }

        if (!$hasPort && isset($serverParams['SERVER_PORT'])) {
            $uri = $uri->withPort($serverParams['SERVER_PORT']);
        }

        $hasQuery = false;
        if (isset($serverParams['REQUEST_URI'])) {
            $requestUriParts = explode('?', $serverParams['REQUEST_URI'], 2);
            $uri = $uri->withPath($requestUriParts[0]);
            if (count($requestUriParts) > 1) {
                $hasQuery = true;
                $uri = $uri->withQuery($requestUriParts[1]);
            }
        }

        if (!$hasQuery && isset($serverParams['QUERY_STRING'])) {
            $uri = $uri->withQuery($serverParams['QUERY_STRING']);
        }

        return $uri;
    }
418275
protected function prepareUri($server)
    {
        $uri = new Uri('');

        if ((isset($server['HTTPS']) && $server['HTTPS'] != 'off') ||
            (isset($server['HTTP_X_FORWARDED_PROTO']) && $server['HTTP_X_FORWARDED_PROTO'] == 'https')
        ) {
            $schema = 'https';
        } else {
            $schema = 'http';
        }

        $parsedUrl = parse_url($server['REQUEST_URI']);
        $username = isset($server['PHP_AUTH_USER']) ? $server['PHP_AUTH_USER'] : null;
        $password = isset($server['PHP_AUTH_PW']) ? $server['PHP_AUTH_PW'] : null;

        return $uri->withScheme($schema)
            ->withHost($server['HTTP_HOST'])
            ->withPort($server['SERVER_PORT'])
            ->withPath(isset($parsedUrl['path']) ? $parsedUrl['path'] : '/')
            ->withUserInfo($username, $password)
            ->withQuery(isset($parsedUrl['query']) ? $parsedUrl['query'] : '');
    }
1309412
public function resolve(UriInterface $uri, UriInterface $baseUri)
    {
        $baseUriReflector = new ReflectionObject($baseUri);
        if (!$baseUriReflector->hasMethod('resolve')) {
            $baseUri = new Uri($baseUri->toString());
            if ($uri instanceof Uri) {
                $uri = clone $uri;
            } else {
                $uri = new Uri($uri->toString());
            }
        } elseif (!$uri instanceof $baseUri) {
            $uri = $baseUriReflector->newInstance($uri->toString());
        } else {
            $uri = clone $uri;
        }

        return $uri->resolve($baseUri);
    }
1141823
public static function createFromUri(
        $uri,
        $script = null,
        array $server = [],
        array $query = [],
        array $parsedBody = null,
        array $cookies = [],
        array $files = []
    ) {
        $server = $server ?: $_SERVER;

        if ($script) {
            $server['SCRIPT_NAME'] = $script;
        }

        $server['SCRIPT_NAME'] = '/' . ltrim($server['SCRIPT_NAME'], '/');

        $request = static::createFromGlobals($server, $query, $parsedBody, $cookies, $files);

        return $request->withUri(new PsrUri($uri));
    }
161335
function makeUri($uri) {
      $a = parse_url($uri);

      if ( (isset($a['scheme'])) && (isset($a['host'])) ) {
        $this->url = $a;
      } else {
        unset($this->url['query']);
        unset($this->url['fragment']);
        $this->url = array_merge($this->url, $a);
      }

      if ($this->useProxy) {
        $requesturi = 'http://' . $this->url['host'] . (empty($this->url['port']) ? '' : ':' . $this->url['port']) . $this->url['path'] . (empty($this->url['query']) ? '' : '?' . $this->url['query']);
      } else {
        $requesturi = $this->url['path'] . (empty($this->url['query']) ? '' : '?' . $this->url['query']);
      }

      return $requesturi;
    }
388203
public static function createServerRequest($method, $uri): ServerRequestInterface
    {
        if (\is_string($uri)) {
            $uri = Uri::createFromString($uri);
        }

        return new ServerRequest($method, $uri);
    }
234667
public function sapiUri($server = null)
    {
        return new Messages\URI\SAPI(
            $server !== null ? $server : $_SERVER
        );
    }
1302498
public static function hostToUnicode($uri)
    {
        return $uri->withHost((string) (new Host(self::filterUri($uri)->getHost()))->toUnicode());
    }
733723
public function withUri(UriInterface $uri, $preserveHost = false)
    {
        if ($this->getUri() === $uri) {
            return $this;
        }

        $newInstance = clone $this;

        $newInstance->setUri($uri);
        if (!$preserveHost) {
            return $newInstance->withHeader('host', $uri->getHost());
        }
        return $newInstance;
    }