protected function shouldUseServerDigestAuth(HTTP_Request2_Response $response)
    {
        // no sense repeating a request if we don't have credentials
        if (401 != $response->getStatus() || !$this->request->getAuth()) {
            return false;
        }
        if (!$challenge = $this->parseDigestChallenge($response->getHeader('www-authenticate'))) {
            return false;
        }

        $url    = $this->request->getUrl();
        $scheme = $url->getScheme();
        $host   = $scheme . '://' . $url->getHost();
        if ($port = $url->getPort()) {
            if ((0 == strcasecmp($scheme, 'http') && 80 != $port)
                || (0 == strcasecmp($scheme, 'https') && 443 != $port)
            ) {
                $host .= ':' . $port;
            }
        }

        if (!empty($challenge['domain'])) {
            $prefixes = array();
            foreach (preg_split('/\\s+/', $challenge['domain']) as $prefix) {
                // don't bother with different servers
                if ('/' == substr($prefix, 0, 1)) {
                    $prefixes[] = $host . $prefix;
                }
            }
        }
        if (empty($prefixes)) {
            $prefixes = array($host . '/');
        }

        $ret = true;
        foreach ($prefixes as $prefix) {
            if (!empty(self::$challenges[$prefix])
                && (empty($challenge['stale']) || strcasecmp('true', $challenge['stale']))
            ) {
                // probably credentials are invalid
                $ret = false;
            }
            self::$challenges[$prefix] =& $challenge;
        }
        return $ret;
    }
protected function shouldUseServerDigestAuth(HTTP_Request2_Response $response)
    {
        // no sense repeating a request if we don't have credentials
        if (401 != $response->getStatus() || !$this->request->getAuth()) {
            return false;
        }
        if (!$challenge = $this->parseDigestChallenge($response->getHeader('www-authenticate'))) {
            return false;
        }

        $url    = $this->request->getUrl();
        $scheme = $url->getScheme();
        $host   = $scheme . '://' . $url->getHost();
        if ($port = $url->getPort()) {
            if ((0 == strcasecmp($scheme, 'http') && 80 != $port)
                || (0 == strcasecmp($scheme, 'https') && 443 != $port)
            ) {
                $host .= ':' . $port;
            }
        }

        if (!empty($challenge['domain'])) {
            $prefixes = array();
            foreach (preg_split('/\\s+/', $challenge['domain']) as $prefix) {
                // don't bother with different servers
                if ('/' == substr($prefix, 0, 1)) {
                    $prefixes[] = $host . $prefix;
                }
            }
        }
        if (empty($prefixes)) {
            $prefixes = array($host . '/');
        }

        $ret = true;
        foreach ($prefixes as $prefix) {
            if (!empty(self::$challenges[$prefix])
                && (empty($challenge['stale']) || strcasecmp('true', $challenge['stale']))
            ) {
                // probably credentials are invalid
                $ret = false;
            }
            self::$challenges[$prefix] =& $challenge;
        }
        return $ret;
    }
protected function shouldUseServerDigestAuth ( HTTP_Request2_Response $ response ) { // no sense repeating a request if we don't have credentials
 if ( 401 != $ response -> getStatus ( ) || ! $ this -> request -> getAuth ( ) ) { return false ; } if ( ! $ challenge = $ this -> parseDigestChallenge ( $ response -> getHeader ( 'www-authenticate' ) ) ) { return false ; } $ url = $ this -> request -> getUrl ( ) ; $ scheme = $ url -> getScheme ( ) ; $ host = $ scheme . '://' . $ url -> getHost ( ) ; if ( $ port = $ url -> getPort ( ) ) { if ( ( 0 == strcasecmp ( $ scheme , 'http' ) && 80 != $ port ) || ( 0 == strcasecmp ( $ scheme , 'https' ) && 443 != $ port ) ) { $ host .= ':' . $ port ; } } if ( ! empty ( $ challenge [ 'domain' ] ) ) { $ prefixes = array ( ) ; foreach ( preg_split ( '/\\s+/' , $ challenge [ 'domain' ] ) as $ prefix ) { // don't bother with different servers
 if ( '/' == substr ( $ prefix , 0 , 1 ) ) { $ prefixes [ ] = $ host . $ prefix ; } } } if ( empty ( $ prefixes ) ) { $ prefixes = array ( $ host . '/' ) ; } $ ret = true ; foreach ( $ prefixes as $ prefix ) { if ( ! empty ( self :: $ challenges [ $ prefix ] ) && ( empty ( $ challenge [ 'stale' ] ) || strcasecmp ( 'true' , $ challenge [ 'stale' ] ) ) ) { // probably credentials are invalid
 $ ret = false ; } self :: $ challenges [ $ prefix ] = & $ challenge ; } return $ ret ; }
Checks whether another request should be performed with server digest auth

Several conditions should be satisfied for it to return true:
- response status should be 401
- auth credentials should be set in the request object
- response should contain WWW-Authenticate header with digest challenge
- there is either no challenge stored for this URL or new challenge
contains stale=true parameter (in other case we probably just failed
due to invalid username / password)

The method stores challenge values in $challenges static property

@param HTTP_Request2_Response $response response to check

@return   boolean whether another request should be performed
@throws   HTTP_Request2_Exception in case of unsupported challenge parameters
Checks whether another request should be performed with server digest auth