swift-server/async-http-client

Async/await for execute methods with delegate

datwelk opened this issue · 4 comments

Currently there are no async/await variants of the HTTPClient.execute methods that take a Delegate argument. Is there any particular reason not to implement Swift concurrency for those methods, or is this waiting for someone to pick it up?

Many of the delegate methods are no longer necessary in the async/await pattern. For example, the receive-side methods (didReceiveHead, didReceiveBodyPart , didReceiveError, didFinishRequest) are now covered by the Body AsyncSequence.

However, the rest of this was because we would need to rewrite the delegate for Async/Await, and we didn't think it was sufficiently necessary to block the release of the async/await API on that work. So if you're interested in tackling it, we're happy to receive a PR to cover the work!

Thanks. I was looking at the FileDownloadDelegate example, which dispatches I/O to the HTTP client's fileIOThreadPool. This seems slightly harder to implement as an API user in a Swift concurrency context due to the usage of internal properties.

We would recommend not implementing that API in that pattern. Instead, consume the async body sequence and dispatch your I/O to your own NonBlockingFileIO.

Thanks for the pointers @Lukasa, I will close this ticket for now.