function setURL($url)
    {
        $this->url = $url;

        $u = parse_url($url);
        foreach ($u as $k => $v) {
            $this->debug("parsed URL $k = $v");
            $this->$k = $v;
        }

        // add any GET params to path
        if (isset($u['query']) && $u['query'] != '') {
            $this->path .= '?' . $u['query'];
        }

        // set default port
        if (!isset($u['port'])) {
            if ($u['scheme'] == 'https') {
                $this->port = 443;
            } else {
                $this->port = 80;
            }
        }

        $this->uri        = $this->path;
        $this->digest_uri = $this->uri;

        // build headers
        if (!isset($u['port'])) {
            $this->setHeader('Host', $this->host);
        } else {
            $this->setHeader('Host', $this->host . ':' . $this->port);
        }

        if (isset($u['user']) && $u['user'] != '') {
            $this->setCredentials(urldecode($u['user']), isset($u['pass']) ? urldecode($u['pass']) : '');
        }
    }