Skip to content

Commit

Permalink
Small namedtuple refactor (#1329)
Browse files Browse the repository at this point in the history
Plus order consistency because why not..
  • Loading branch information
johtso committed Sep 27, 2020
1 parent a7a76fb commit 32d37cf
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions httpx/_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,11 @@ def _parse_challenge(
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"
Expand Down Expand Up @@ -296,17 +296,9 @@ def _resolve_qop(
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]

0 comments on commit 32d37cf

Please sign in to comment.