Skip to content

Conversation

crazytonyli
Copy link
Contributor

@crazytonyli crazytonyli commented Mar 10, 2024

This PR adds a URLSession helper function to send requests, including their body, which is not possible for now because WPNetworkRequest don't have a body property yet.

Background URLSession

Due to the constraint on background URLSession instances where they can only get HTTP responses via URLSessionDelegate (the dataTask(for:completionHandler:) and similar APIs would simply crash), we have to implement a custom delegate to get them work with our async or closure-based APIs. This should work fine for now, but if in the future we want to accept background URLSession instances created by the clients, we should rethink this special URLSessionDelegate implementation.

Error handling

This PR only includes a very light error handling. And the API-level (i.e. parsing code and message from .org REST API response) error handling will wait once we have a solution on #22.

Base automatically changed from add/ci to trunk March 11, 2024 16:52
@jkmassel
Copy link
Contributor

Depends on #42 – once it lands, we'll need to rebase this PR and can meaningfully review it in the context of Linux / Darwin compatibility

@crazytonyli crazytonyli marked this pull request as draft March 13, 2024 05:56
@crazytonyli
Copy link
Contributor Author

I have turned this PR to draft, because there are some additional work needed regarding Linux support.

@crazytonyli crazytonyli force-pushed the add-url-session-helpers branch from 79ecf42 to 81e08fd Compare March 14, 2024 00:09
OHHTTPStubs can't be compiled on Linux because it depends on the Objective-C
Foundation framework, which is not available on Linux.
@crazytonyli crazytonyli force-pushed the add-url-session-helpers branch from 81e08fd to d4499fc Compare March 14, 2024 00:10
@crazytonyli crazytonyli marked this pull request as ready for review March 14, 2024 00:35
@crazytonyli crazytonyli force-pushed the add-url-session-helpers branch from 317db2c to 3a90947 Compare March 14, 2024 00:55
@oguzkocer oguzkocer removed their request for review July 23, 2024 18:52
@crazytonyli
Copy link
Contributor Author

Closing this PR as none of the changes are really needed at the moment. The progress tracking might be useful, but we can bring that into the trunk branch when it's needed by the apps.

@jkmassel jkmassel deleted the add-url-session-helpers branch November 20, 2024 05:30
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.

2 participants