reuse the digest auth state to avoid unnecessary requests#2463
Merged
lovelydinosaur merged 9 commits intoencode:masterfrom Nov 29, 2022
Merged
reuse the digest auth state to avoid unnecessary requests#2463lovelydinosaur merged 9 commits intoencode:masterfrom
lovelydinosaur merged 9 commits intoencode:masterfrom
Conversation
2 tasks
tests/client/test_auth.py
Outdated
| @pytest.mark.asyncio | ||
| async def test_digest_auth_reuses_challenge() -> None: | ||
| url = "https://example.org/" | ||
| auth = DigestAuth(username="tomchristie", password="password123") |
Contributor
There was a problem hiding this comment.
Suggested change
| auth = DigestAuth(username="tomchristie", password="password123") | |
| auth = DigestAuth(username="user", password="password123") |
tests/client/test_auth.py
Outdated
| @pytest.mark.asyncio | ||
| async def test_digest_auth_resets_nonce_count_after_401() -> None: | ||
| url = "https://example.org/" | ||
| auth = DigestAuth(username="tomchristie", password="password123") |
Contributor
There was a problem hiding this comment.
Suggested change
| auth = DigestAuth(username="tomchristie", password="password123") | |
| auth = DigestAuth(username="user", password="password123") |
Contributor
lovelydinosaur
left a comment
There was a problem hiding this comment.
Great stuff - thanks!
A few minor suggestions here.
Contributor
Author
|
I have refactored some code in view of your suggestions. Regarding the failing test pipeline i assume this is not an issue with my branch, as other pipelines seem to fail with the same error message? |
Contributor
Yup. See #2465 |
lovelydinosaur
approved these changes
Nov 28, 2022
Contributor
|
Good work, thanks! |
Merged
samclearman
pushed a commit
to titanmsp/httpx
that referenced
this pull request
Apr 26, 2025
* reuse the digest auth challenge to avoid sending twice as many requests * fix for digest testcase * ran testing/linting scripts * codereview changes, removed tomchristie username from all authentication tests Co-authored-by: Philipp Reitter <p.reitter@accessio.at> Co-authored-by: Tom Christie <tom@tomchristie.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
this implements digest authentication state reuse as discussed in #1467.
Contrary to the comment i am not skipping most of the authentication flow if a previous challenge exists. Otherwise a failed authentication (401) would not result in a retry with the new server challenge (
test_digest_auth_resets_nonce_count_after_401would fail).