src/Http/Request.php
public function withUri(UriInterface $uri, $preserve = false)
    {
        $static = clone $this;

        $static->uri = $uri;

        if (! $preserve && $host = $uri->getHost()) {
            $port = $host . ':' . $uri->getPort();

            $host = $uri->getPort() ? $port : $host;

            $static->headers['Host'] = (array) $host;
        }

        return $static;
    }
public function withUri(UriInterface $uri, $preserve = false)
    {
        $static = clone $this;

        $static->uri = $uri;

        if (! $preserve && $host = $uri->getHost()) {
            $port = $host . ':' . $uri->getPort();

            $host = $uri->getPort() ? $port : $host;

            $static->headers['Host'] = (array) $host;
        }

        return $static;
    }
Returns an instance with the provided URI.

@param  \Psr\Http\Message\UriInterface $uri
@param  boolean                        $preserve
@return static