Fix URLSessionProxy async uploads ignoring the task delegate - #381
Draft
ffittschen wants to merge 1 commit into
Draft
ffittschen wants to merge 1 commit into
ffittschen wants to merge 1 commit into
Conversation
URLSessionProxy.upload(for:from:delegate:) and upload(for:fromFile:delegate:) create a URLSessionProxyDelegate that wraps the caller's delegate, but never pass it to URLSession: - the caller's task delegate was silently ignored, so it got no authentication challenges or progress callbacks; - the proxy never saw the created task, so it never logged the completion: the upload stayed pending in the console, without its response. Pass the delegate, like data(for:delegate:) and download(for:delegate:) already do.
This was referenced Sep 29, 2026
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.
This PR fixes
URLSessionProxy.upload(for:from:delegate:)andupload(for:fromFile:delegate:)ignoring the caller's delegate. The root cause was that both wrap the delegate in aURLSessionProxyDelegatebut never pass it toURLSession. As a result, the caller's task delegate gets no callbacks, so an auth challenge goes unanswered and the call returns 401. The proxy also never sees the created task, so the upload stays pending in the console forever. The fix passes the delegate, asdata(for:delegate:)anddownload(for:delegate:)already do.Found while working on #378.
How to test
URLSessionProxy.upload(for:from:delegate:)to an endpoint that asks for Basic auth, with a delegate that answers the challenge. Assert that the delegate gets the challenge, the call returns 200, and the console shows the task as completed.upload(for:fromFile:delegate:).