Skip to content

fix: apply digest auth to the HTTP/2 fallback - #613

Merged
Mzack9999 merged 1 commit into
mainfrom
dwisiswant0/fix/apply-digest-auth-to-the-http-2-fallback
Oct 26, 2026
Merged

Mzack9999 merged 1 commit into
mainfrom
dwisiswant0/fix/apply-digest-auth-to-the-http-2-fallback

Conversation

@dwisiswant0

Copy link
Copy Markdown
Member

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

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
Mzack9999 merged commit f079b0d into main Oct 26, 2026
7 checks passed
@Mzack9999
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTP/2 fallback drops digest auth

2 participants