Add URLSessionTaskDelegate parameter to WordPressAPI
#1042
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.
The consumer can now pass a
URLSessionTaskDelegateinstance to get notified of URLSession tasks that the Rust library sends.At the moment, only a subset of
URLSessionTaskDelegateandURLSessionDataDelegatefunctions will be called on the new parameter.In the implementation, I had to stop using the async functions like
await data(for: request, delegate: ...), and manually implement an async function using thedataTask(...)API. That's because the URLSession does not call thedelegate's task result functions (didReceiveData,didReceiveResponse,didCompleteWithError), when the caller uses an API that returns the HTTP response. To make sure all the functions in the newnotifyingDelegate: URLSessionTaskDelegateparameter get called, we had to manually workaround the URLSession constraints. Additionally, theasync data(for: request, delegate: ...)API is not available API. If we want to support the new feature across all platforms, we have to implement the async API ourselves.