fix(webdav): retry stale digest authentication - #9616
Open
otiscuilei wants to merge 1 commit into
Open
Conversation
otiscuilei
force-pushed
the
fix/webdav-refresh-stale-digest-nonce
branch
from
August 12, 2026 12:00
e14ecd8 to
1ab440c
Compare
Collaborator
|
This looks solid to me. Checked the DigestAuth struct literal lines up with the field order {user, pw, digestParts}, the retry is bounded to a single stale challenge so theres no runaway recursion, and the response body gets closed before each retry. Tests cover both the happy path and the bounded case, which is what I wanted to see. One tiny thing, not a blocker: the !canRetry stale branch returns without closing rs.Body, but the neighboring 401 branches do the same, so at least its consistent. Happy to merge. |
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.
What this changes
Refreshes Digest authentication when a WebDAV server rejects an expired nonce with a new
WWW-Authenticatechallenge containingstale=true.Previously, the first Digest challenge was handled, but any later 401 from an already active
DigestAuthimmediately returned an authorization error. Servers that periodically expire nonces therefore became unusable until the client was recreated.The retry is deliberately bounded to one stale challenge so a misbehaving server cannot cause unbounded recursion. Responses are closed before retrying so the underlying connection can be reused safely.
Tests
httptestWebDAV flow covering initial authentication, nonce expiry, refreshed authentication, and successgo test ./pkg/gowebdav -count=1pkg/...tests pass except the existingpkg/aria2/rpcintegration tests, which require an aria2 server onlocalhost:6800Fixes #7556