Preface: I've been developing a Vapor Server in Swift 5.7 on my iMac, running the latest development binary (July 5th) on a linux machine (using AUR (en) - swift-bin-development).
The method "data(for request: URLRequest, delegate:) async throws -> (Data, URLResponse)" no longer exists in the URLSession, and I am writing here to figure out how to achieve the same thing without this function, or locate where it went in the new FoundationNetworking module (from GitHub - apple/swift-corelibs-foundation: The Foundation Project, providing core utilities, internationalization, and OS independence). I tried looking at the source code and other branches that support async-await for anything that can help me figure this out, but couldn't find a fix or workaround without reverting back to completion handlers (my project is deeply coded in async-await).
This is the final error I need to fix before production, and any help relating to this is greatly appreciated!
I found some helpful links relating to this issue
As an aside you probably don't want to be using URLSession in a Vapor app. URLSession works well for a client with one user but it doesn't integrate with EventLoops, you don't get to take advantage of connection pooling and a host of other issues. You should use AsyncHTTPClient and Vapor provides that via req.client and app.client. It also has functions for decoding Content etc, using the same HTTPHeaders so I recommend just using that.
I use the AsyncHTTPClient and AsyncResponseEncodable for client stuff along side actors for caching, but use URLSession for server stuff (web scraping, third-party API requests). I'll have to downgrade to 5.6 for now.
PS: thank you for you work on Vapor, I love and support the project (Leaf as-well) <3
I understand now; just converted to Vapor's Client, and everything builds and works as intended, except TLS. NIOSSL can't find my certificate files. I tried some hard-coded fixes, config changes, a server reboot, and even generated a new certificate, but nothing fixed it. The files were generated from Certbot (Let's Encrypt) as sudo, as required. I attached the stacktrace of the error + my new certificate paths.