Revised the documentation of the Client class and the calc_response function.

This commit is contained in:
依瑪貓 2022-12-06 18:01:01 +08:00
parent a6dc530ac7
commit 6057fc0987
2 changed files with 11 additions and 11 deletions

View File

@ -47,15 +47,15 @@ def calc_response(
:param uri: The request URI. :param uri: The request URI.
:param password_hash: The password hash for the HTTP digest authentication. :param password_hash: The password hash for the HTTP digest authentication.
:param nonce: The nonce. :param nonce: The nonce.
:param qop: the quality of protection, either "auth" or "auth-int". :param qop: the quality of protection, either ``auth`` or ``auth-int``.
:param algorithm: The algorithm, either "MD5" or "MD5-sess". :param algorithm: The algorithm, either ``MD5`` or ``MD5-sess``.
:param cnonce: The client nonce, which must exists when qop exists or :param cnonce: The client nonce, which must exists when qop exists or
algorithm="MD5-sess". algorithm is ``MD5-sess``.
:param nc: The request counter, which must exists when qop exists. :param nc: The request counter, which must exists when qop exists.
:param body: The request body, which must exists when qop="auth-int". :param body: The request body, which must exists when qop is ``auth-int``.
:return: The response value. :return: The response value.
:raise AssertionError: When cnonce is missing with the :raise AssertionError: When cnonce is missing with algorithm is
algorithm="MD5-sess", when body is missing with qop="auth-int", or when ``MD5-sess``, when body is missing with qop is ``auth-int``, or when
cnonce or nc is missing with qop exits. cnonce or nc is missing with qop exits.
""" """
@ -64,7 +64,7 @@ def calc_response(
:return: The first hash. :return: The first hash.
:raise AssertionError: When cnonce is missing with :raise AssertionError: When cnonce is missing with
algorithm="MD5-sess". algorithm is ``MD5-sess``.
""" """
if algorithm == "MD5-sess": if algorithm == "MD5-sess":
assert cnonce is not None,\ assert cnonce is not None,\
@ -78,7 +78,7 @@ def calc_response(
"""Calculates the second hash. """Calculates the second hash.
:return: The second hash. :return: The second hash.
:raise AssertionError: When body is missing with qop="auth-int". :raise AssertionError: When body is missing with qop is ``auth-int``.
""" """
if qop == "auth-int": if qop == "auth-int":
assert body is not None, f"Missing \"body\" with qop=\"{qop}\"" assert body is not None, f"Missing \"body\" with qop=\"{qop}\""

View File

@ -36,8 +36,8 @@ class Client(WerkzeugClient):
"""Opens a request. """Opens a request.
:param args: The arguments. :param args: The arguments.
:param digest_auth: The username and password for the HTTP digest :param digest_auth: A tuple of the username and password for the HTTP
authentication. digest authentication.
:param kwargs: The keyword arguments. :param kwargs: The keyword arguments.
:return: The response. :return: The response.
""" """
@ -59,7 +59,7 @@ class Client(WerkzeugClient):
username: str, password: str) -> Authorization: username: str, password: str) -> Authorization:
"""Composes and returns the request authorization. """Composes and returns the request authorization.
:param www_authenticate: The WWW-Authenticate response. :param www_authenticate: The ``WWW-Authenticate`` response.
:param uri: The request URI. :param uri: The request URI.
:param username: The username. :param username: The username.
:param password: The password. :param password: The password.