public function setUrl($url) {
        // Parse the url and set the individual components.
        $url_parts = parse_url($url);

        if (isset($url_parts['scheme'])) {
            $this->setScheme($url_parts['scheme']);
        }

        if (isset($url_parts['host'])) {
            $this->setHost($url_parts['host']);
        }

        if (isset($url_parts['port'])) {
            $this->setPort($url_parts['port']);
        } elseif (isset($url_parts['scheme'])) {
            $this->setPort($this->getScheme() === 'https' ? 443 : 80);
        }

        if (isset($url_parts['path'])) {
            $this->setFullPath($url_parts['path']);
        }

        if (isset($url_parts['query'])) {
            parse_str($url_parts['query'], $query);
            if (is_array($query)) {
                $this->setQuery($query);
            }
        }
        return $this;
    }