Repository navigation
fix: answer digest challenges with the caller's request - #616
Merged
Mzack9999 merged 1 commit intoOct 26, 2026
Conversation
send passed DigestAuth requests to go-http-digest-auth-client, whose RoundTrip builds new requests from the method, URL, body, and User-Agent alone. Every other header, the request context (deadline, cancellation, and httptrace hooks), and fields such as Host were lost. For digest auth, send now sends a clone of the caller's request and, on a 401 with a Digest challenge, a second clone with an Authorization header added. Both clones read a copy of the body, because a server that rejects a large body may stop reading it partway and would leave req.Body unusable for the second request and for retries. The library can't compute the header on its own, so this adds a small RFC 7616 client (MD5, SHA-256, and SHA-512-256, their -sess variants, auth and auth-int, and userhash) that also reads several challenges from one WWW-Authenticate value, and drops the dependency. When no challenge can be answered, the caller gets the server's 401 response unchanged. Fixes: #614 Refs: #613 Signed-off-by: Dwi Siswanto <git@dw1.io>
Member
Author
|
Stacked. |
Mzack9999
approved these changes
Oct 26, 2026
Mzack9999
deleted the
dwisiswant0/fix/answer-digest-challenges-with-the-callers-request
branch
October 26, 2026 19:48
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.
send passed DigestAuth requests to go-http-digest-auth-client, whose RoundTrip builds new requests from the method, URL, body, and User-Agent alone. Every other header, the request context (deadline, cancellation, and httptrace hooks), and fields such as Host were lost.
For digest auth, send now sends a clone of the caller's request and, on a 401 with a Digest challenge, a second clone with an Authorization header added. Both clones read a copy of the body, because a server that rejects a large body may stop reading it partway and would leave req.Body unusable for the second request and for retries.
The library can't compute the header on its own, so this adds a small RFC 7616 client (MD5, SHA-256, and SHA-512-256, their -sess variants, auth and auth-int, and userhash) that also reads several challenges from one WWW-Authenticate value, and drops the dependency. When no challenge can be answered, the caller gets the server's 401 response unchanged.
Fixes: #614
Refs: #613