def response(credentials, password, request):
response = None<EOL>algorithm = credentials.get('<STR_LIT>')<EOL>HA1_value = HA1(<EOL>credentials.get('<STR_LIT>'),<EOL>credentials.get('<STR_LIT:username>'),<EOL>password,<EOL>algorithm<EOL>)<EOL>HA2_value = HA2(credentials, request, algorithm)<EOL>if credentials.get('<STR_LIT>') is None:<EOL><INDENT>response = H(b"<STR_LIT::>".join([<EOL>HA1_value.encode('<STR_LIT:utf-8>'),<EOL>credentials.get('<STR_LIT>', '<STR_LIT>').encode('<STR_LIT:utf-8>'),<EOL>HA2_value.encode('<STR_LIT:utf-8>')<EOL>]), algorithm)<EOL><DEDENT>elif credentials.get('<STR_LIT>') == '<STR_LIT>' or credentials.get('<STR_LIT>') == '<STR_LIT>':<EOL><INDENT>for k in '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>':<EOL><INDENT>if k not in credentials:<EOL><INDENT>raise ValueError("<STR_LIT>" % k)<EOL><DEDENT><DEDENT>response = H(b"<STR_LIT::>".join([HA1_value.encode('<STR_LIT:utf-8>'),<EOL>credentials.get('<STR_LIT>').encode('<STR_LIT:utf-8>'),<EOL>credentials.get('<STR_LIT>').encode('<STR_LIT:utf-8>'),<EOL>credentials.get('<STR_LIT>').encode('<STR_LIT:utf-8>'),<EOL>credentials.get('<STR_LIT>').encode('<STR_LIT:utf-8>'),<EOL>HA2_value.encode('<STR_LIT:utf-8>')]), algorithm)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>return response<EOL>
Compile digest auth response

    If the qop directive's value is "auth" or "auth-int" , then compute the response as follows:
       RESPONSE = MD5(HA1:nonce:nonceCount:clienNonce:qop:HA2)
    Else if the qop directive is unspecified, then compute the response as follows:
       RESPONSE = MD5(HA1:nonce:HA2)

    Arguments:
    - `credentials`: credentials dict
    - `password`: request user password
    - `request`: request dict