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;
    }