Skip to content

Add async URLSession methods #4970

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 6, 2024
Merged

Conversation

jrflat
Copy link
Contributor

@jrflat jrflat commented Jun 4, 2024

Thanks to @b1ackturtle for providing the foundation of this work in #4705!

This PR implements the remaining async URLSession methods and the URLSessionTask.delegate property, allowing a delegate to be set in the async methods (or in a non-async context before resumption). URLSessionTask.delegate returns the explicitly set delegate if present, otherwise returns the session delegate as? URLSessionTaskDelegate. It's now used wherever we previously casted the session delegate to URLSessionTaskDelegate. To accompany this change, functions in extension URLSessionTaskDelegate (which are called if not implemented by the task's delegate) now check if the session's delegate implements it and call the session's delegate if that's the case.

@jrflat
Copy link
Contributor Author

jrflat commented Jun 4, 2024

@swift-ci please test

@jrflat jrflat merged commit ff64e86 into swiftlang:main Jun 6, 2024
2 of 3 checks passed
jrflat added a commit to jrflat/swift-corelibs-foundation that referenced this pull request Jun 6, 2024
* Add `data(from:delegate:)` method.

* Add async URLSession methods

---------

Co-authored-by: ichiho <[email protected]>
trunk-io bot pushed a commit to Tyler-Keith-Thompson/Afluent that referenced this pull request Mar 19, 2025
With [this PR](swiftlang/swift-corelibs-foundation#4970), the async/await URLSession functions are now available on other OS's, but only in swift 6.

Updates `URLSessionAdditions.swift` to also check for swift 6, and enable these urlsession -> afluent bridge functions when possible.
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.

3 participants