public function replaceHost($newUrl, $opt = self::SCHEME | self::HOST | self::PORT | self::CREDENTIALS)
	{
		if ($newUrl instanceof Url) {
			$url = $newUrl;
		} else if (is_string($newUrl)) {
			$url = new Url($newUrl);
		} else {
			throw new InvalidUrlException();
		}
		$scheme = ($opt & self::SCHEME) === self::SCHEME;
		$host = ($opt & self::HOST) === self::HOST;
		$port = ($opt & self::PORT) === self::PORT;
		$creds = ($opt & self::CREDENTIALS) === self::CREDENTIALS;
		if ($scheme) {
			$this->scheme->set($url->scheme->get());
		}
		if ($host) {
			$this->host->set($url->host->get());
		}
		if ($port) {
			$this->port->set($url->port->get());
		}
		if ($creds) {
			$this->credentials->username = $url->credentials->username;
			$this->credentials->password = $url->credentials->password;
		}
		return $this;
	}