'Clear the auth info and enable digest auth.'

def set_digest(self, realm, nonce, qop=('auth',), opaque=None, algorithm=None, stale=False):

    d = {'__auth_type__': 'digest', 'realm': realm, 'nonce': nonce, 'qop': dump_header(qop)}
    if stale:
        d['stale'] = 'TRUE'
    if (opaque is not None):
        d['opaque'] = opaque
    if (algorithm is not None):
        d['algorithm'] = algorithm
    dict.clear(self)
    dict.update(self, d)
    if self.on_update:
        self.on_update(self)
