private function digest_auth() {

        $headers = array();
        $headers[] = sprintf('%s %s %s', 'HEAD', $this->_path, $this->_protocol);
        $headers[] = sprintf('Host: %s:%s', $this->_server, $this->_port);
        $headers[] = sprintf('User-Agent: %s', $this->_user_agent);
        $headers = implode("\r\n", $headers);
        $headers .= "\r\n\r\n";
        fputs($this->sock, $headers);

        // Reads the headers.
        $i = 0;
        $header = '';
        do {
            $header .= fread($this->sock, 1);
            $i++;
        } while (!preg_match('/\\r\\n\\r\\n$/', $header, $matches) && $i < $this->_maxheaderlenth);

        // Analyse the headers.
        $digest = array();
        $splitheaders = explode("\r\n", $header);
        foreach ($splitheaders as $line) {
            if (!preg_match('/^WWW-Authenticate: Digest/', $line)) {
                continue;
            }
            $line = substr($line, strlen('WWW-Authenticate: Digest '));
            $params = explode(',', $line);
            foreach ($params as $param) {
                list($key, $value) = explode('=', trim($param), 2);
                $digest[$key] = trim($value, '"');
            }
            break;
        }

        $this->_digestchallenge = $digest;
    }