Repository navigation
fix: apply digest auth to the HTTP/2 fallback - #613
Merged
Mzack9999 merged 1 commit intoOct 26, 2026
Merged
Conversation
When a digest-auth request failed with `malformed HTTP version "HTTP/2"` or `malformed HTTP response`, Do retried it with HTTPClient2.Do, outside the digest transport. The retry carried no Authorization header, so the caller got the server's 401. Digest support only wrapped the first attempt; the older HTTP/2 fallback kept its own direct call. Move the choice between a digest and a plain send into send(hc, req) and use it for both attempts, so they differ only in the client. Fixes: #601 Signed-off-by: Dwi Siswanto <git@dw1.io>
Mzack9999
approved these changes
Oct 26, 2026
Mzack9999
deleted the
dwisiswant0/fix/apply-digest-auth-to-the-http-2-fallback
branch
October 26, 2026 19:48
Mzack9999
pushed a commit
that referenced
this pull request
Oct 26, 2026
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>
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.
When a digest-auth request failed with
malformed HTTP version "HTTP/2"or
malformed HTTP response, Do retried it with HTTPClient2.Do,outside the digest transport. The retry carried no Authorization
header, so the caller got the server's 401.
Digest support only wrapped the first attempt; the older HTTP/2
fallback kept its own direct call. Move the choice between a digest and
a plain send into send(hc, req) and use it for both attempts, so they
differ only in the client.
Fixes: #601