(self, method, request_uri, headers, content, cnonce = None)
Modify the request headers
Modify the request headers
Modify the request headers
def request(self, method, request_uri, headers, content, cnonce = None):
        """Modify the request headers"""
        H = lambda x: _md5(x).hexdigest()
        KD = lambda s, d: H("%s:%s" % (s, d))
        A2 = "".join([method, ":", request_uri])
        self.challenge['cnonce'] = cnonce or _cnonce()
        request_digest  = '"%s"' % KD(H(self.A1), "%s:%s:%s:%s:%s" % (
                self.challenge['nonce'],
                '%08x' % self.challenge['nc'],
                self.challenge['cnonce'],
                self.challenge['qop'], H(A2)))
        headers['authorization'] = 'Digest username="%s", realm="%s", nonce="%s", uri="%s", algorithm=%s, response=%s, qop=%s, nc=%08x, cnonce="%s"' % (
                self.credentials[0],
                self.challenge['realm'],
                self.challenge['nonce'],
                request_uri,
                self.challenge['algorithm'],
                request_digest,
                self.challenge['qop'],
                self.challenge['nc'],
                self.challenge['cnonce'])
        if self.challenge.get('opaque'):
            headers['authorization'] += ', opaque="%s"' % self.challenge['opaque']
        self.challenge['nc'] += 1
def request ( self , method , request_uri , headers , content , cnonce = None ) : H = lambda x : _md5 ( x ) . hexdigest ( ) KD = lambda s , d : H ( "%s:%s" % ( s , d ) ) A2 = "" . join ( [ method , ":" , request_uri ] ) self . challenge [ 'cnonce' ] = cnonce or _cnonce ( ) request_digest = '"%s"' % KD ( H ( self . A1 ) , "%s:%s:%s:%s:%s" % ( self . challenge [ 'nonce' ] , '%08x' % self . challenge [ 'nc' ] , self . challenge [ 'cnonce' ] , self . challenge [ 'qop' ] , H ( A2 ) ) ) headers [ 'authorization' ] = 'Digest username="%s", realm="%s", nonce="%s", uri="%s", algorithm=%s, response=%s, qop=%s, nc=%08x, cnonce="%s"' % ( self . credentials [ 0 ] , self . challenge [ 'realm' ] , self . challenge [ 'nonce' ] , request_uri , self . challenge [ 'algorithm' ] , request_digest , self . challenge [ 'qop' ] , self . challenge [ 'nc' ] , self . challenge [ 'cnonce' ] ) if self . challenge . get ( 'opaque' ) : headers [ 'authorization' ] += ', opaque="%s"' % self . challenge [ 'opaque' ] self . challenge [ 'nc' ] += 1