Repository navigation
gh-53089: Send uri="/" in Digest auth for URLs with an empty path - #161009
Merged
Merged
Conversation
For a URL such as http://example.com, the request selector is empty. AbstractDigestAuthHandler.get_authorization() used it as-is, sending uri="" and hashing "GET:" while http.client sends "GET /" on the request line, so servers rejected the request or failed the digest check. Normalize an empty selector to '/', as http.client does, for both the uri field and A2. Also replace the long-standing "XXX selector: what about proxies and full urls" note with a comment explaining that the digest-uri is the request-target as sent (absolute-form through an HTTP proxy), which RFC 7616 allows, and add a test pinning that behavior. Co-Authored-By: Claude Opus 5.5 <[email protected]>
orsenthil
enabled auto-merge (squash)
October 31, 2026 15:28
|
Thanks @orsenthil for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15. |
|
GH-161013 is a backport of this pull request to the 3.15 branch. |
|
GH-161014 is a backport of this pull request to the 3.14 branch. |
orsenthil
added a commit
that referenced
this pull request
Oct 31, 2026
…ath (GH-161009) (#161014) gh-53089: Send uri="/" in Digest auth for URLs with an empty path (GH-161009) For a URL such as http://example.com, the request selector is empty. AbstractDigestAuthHandler.get_authorization() used it as-is, sending uri="" and hashing "GET:" while http.client sends "GET /" on the request line, so servers rejected the request or failed the digest check. Normalize an empty selector to '/', as http.client does, for both the uri field and A2. Also replace the long-standing "XXX selector: what about proxies and full urls" note with a comment explaining that the digest-uri is the request-target as sent (absolute-form through an HTTP proxy), which RFC 7616 allows, and add a test pinning that behavior. (cherry picked from commit 663e99d) Co-authored-by: Senthil Kumaran <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
orsenthil
added a commit
that referenced
this pull request
Oct 31, 2026
…ath (GH-161009) (#161013) gh-53089: Send uri="/" in Digest auth for URLs with an empty path (GH-161009) For a URL such as http://example.com, the request selector is empty. AbstractDigestAuthHandler.get_authorization() used it as-is, sending uri="" and hashing "GET:" while http.client sends "GET /" on the request line, so servers rejected the request or failed the digest check. Normalize an empty selector to '/', as http.client does, for both the uri field and A2. Also replace the long-standing "XXX selector: what about proxies and full urls" note with a comment explaining that the digest-uri is the request-target as sent (absolute-form through an HTTP proxy), which RFC 7616 allows, and add a test pinning that behavior. (cherry picked from commit 663e99d) Co-authored-by: Senthil Kumaran <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
For a URL such as http://example.com, the request selector is empty. AbstractDigestAuthHandler.get_authorization() used it as-is, sending uri="" and hashing "GET:" whereas http.client sends "GET /" on the request line (see https://github.com/python/cpython/blob/main/Lib/http/client.py#L1248-L1250) , so servers rejected the request or failed the digest check.
This is an internal consistency within urllib and URI via http.client. This is long standing bug and should be fixed.
Normalize an empty selector to '/', as http.client does, for both the uri field and A2.
Also replace the long-standing "XXX selector: what about proxies and full urls" note with a comment explaining that the digest-uri is the request-target as sent (absolute-form through an HTTP proxy), which RFC 7616 allows, and add a test pinning that behavior.