MCPcopy
hub / github.com/encode/httpx / challenge_send

Method challenge_send

tests/client/test_auth.py:59–84  ·  view source on GitHub ↗
(self, request: httpx.Request)

Source from the content-addressed store, hash-verified

57 return httpx.Response(200, json=data)
58
59 def challenge_send(self, request: httpx.Request) -> httpx.Response:
60 self._response_count += 1
61 nonce = (
62 hashlib.sha256(os.urandom(8)).hexdigest()
63 if self._regenerate_nonce
64 else "ee96edced2a0b43e4869e96ebe27563f369c1205a049d06419bb51d8aeddf3d3"
65 )
66 challenge_data = {
67 "nonce": nonce,
68 "qop": self.qop,
69 "opaque": (
70 "ee6378f3ee14ebfd2fff54b70a91a7c9390518047f242ab2271380db0e14bda1"
71 ),
72 "algorithm": self.algorithm,
73 "stale": "FALSE",
74 }
75 challenge_str = ", ".join(
76 '{}="{}"'.format(key, value)
77 for key, value in challenge_data.items()
78 if value
79 )
80
81 headers = {
82 "www-authenticate": f'Digest realm="httpx@example.org", {challenge_str}',
83 }
84 return httpx.Response(401, headers=headers)
85
86
87class RepeatAuth(httpx.Auth):

Callers 1

__call__Method · 0.95

Calls 2

joinMethod · 0.80
itemsMethod · 0.45

Tested by

no test coverage detected