'Takes the given response and tries digest-auth, if needed.'

def handle_401(self, r):

    num_401_calls = r.request.hooks['response'].count(self.handle_401)
    s_auth = r.headers.get('www-authenticate', '')
    if (('digest' in s_auth.lower()) and (num_401_calls < 2)):
        self.chal = parse_dict_header(s_auth.replace('Digest    ', ''))
        r.content
        r.raw.release_conn()
        r.request.headers['Authorization'] = self.build_digest_header(r.request.method, r.request.url)
        _r = r.connection.send(r.request)
        _r.history.append(r)
        return _r
    return r
