From: Johannes Date: Sun, 27 Sep 2020 20:15:04 +0000 (+0100) Subject: Small namedtuple refactor (#1329) X-Git-Tag: 0.15.5~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32d37cfdf1697f0dbacbc2233ee34606369be87b;p=thirdparty%2Fhttpx.git Small namedtuple refactor (#1329) Plus order consistency because why not.. --- diff --git a/httpx/_auth.py b/httpx/_auth.py index c91ab7b9..343f9cdd 100644 --- a/httpx/_auth.py +++ b/httpx/_auth.py @@ -197,11 +197,11 @@ class DigestAuth(Auth): try: realm = header_dict["realm"].encode() nonce = header_dict["nonce"].encode() - qop = header_dict["qop"].encode() if "qop" in header_dict else None - opaque = header_dict["opaque"].encode() if "opaque" in header_dict else None algorithm = header_dict.get("algorithm", "MD5") + opaque = header_dict["opaque"].encode() if "opaque" in header_dict else None + qop = header_dict["qop"].encode() if "qop" in header_dict else None return _DigestAuthChallenge( - realm=realm, nonce=nonce, qop=qop, opaque=opaque, algorithm=algorithm + realm=realm, nonce=nonce, algorithm=algorithm, opaque=opaque, qop=qop ) except KeyError as exc: message = "Malformed Digest WWW-Authenticate header" @@ -296,17 +296,9 @@ class DigestAuth(Auth): raise ProtocolError(message, request=request) -class _DigestAuthChallenge: - def __init__( - self, - realm: bytes, - nonce: bytes, - algorithm: str, - opaque: typing.Optional[bytes] = None, - qop: typing.Optional[bytes] = None, - ) -> None: - self.realm = realm - self.nonce = nonce - self.algorithm = algorithm - self.opaque = opaque - self.qop = qop +class _DigestAuthChallenge(typing.NamedTuple): + realm: bytes + nonce: bytes + algorithm: str + opaque: typing.Optional[bytes] + qop: typing.Optional[bytes]