swiftly icon indicating copy to clipboard operation
swiftly copied to clipboard

Possible usage of URLSession For Greater Portability

Open brianmichel opened this issue 2 years ago • 5 comments

On a lark this weekend I was curious to see if it'd be possible to get swiftly ported to Windows. When I pulled the project down I noticed that a bunch of the NIO stuff doesn't seem to work out of the box on Windows (this is likely fixable, but it prompted me to look at what it was being used for).

It seems like it's primarily being used to build an HTTP client and I was wondering if it's feasible/desirable to switch to using URLSession from Foundation to make this a bit more portable. I don't know if there were specific limitations with that framework which prevented it from being chosen, but I figured I'd start the discussion since managing different toolchains on Windows is also quite a pain!

brianmichel avatar Oct 15 '23 20:10 brianmichel

@patrickfreed Do you think this is something we could hide behind HTTPClientWrapper.

adam-fowler avatar Oct 25 '23 09:10 adam-fowler

Hey, sorry for the late response on this. Our usage of AsyncHTTPClient could definitely be replaced with URLSession, there's no technical requirement for it. I opted to use it in swiftly simply because it provided a friendly and async/await-ready API. Dropping NIO as a dependency might make the binary size smaller too, which would be nice.

patrickfreed avatar Nov 03 '23 04:11 patrickfreed

Hey, sorry for the late response on this. Our usage of AsyncHTTPClient could definitely be replaced with URLSession, there's no technical requirement for it. I opted to use it in swiftly simply because it provided a friendly and async/await-ready API. Dropping NIO as a dependency might make the binary size smaller too, which would be nice.

It won't make the binary any smaller on Linux as you have to include FoundationNetworking instead.

adam-fowler avatar Nov 03 '23 07:11 adam-fowler

Hey, sorry for the late response on this. Our usage of AsyncHTTPClient could definitely be replaced with URLSession, there's no technical requirement for it. I opted to use it in swiftly simply because it provided a friendly and async/await-ready API. Dropping NIO as a dependency might make the binary size smaller too, which would be nice.

It won't make the binary any smaller on Linux as you have to include FoundationNetworking instead.

Good points! I mostly was just thinking for cross platform availability, less of binary size :D

brianmichel avatar Nov 03 '23 12:11 brianmichel

We should probably support both and chose one based on which platform we are running on

adam-fowler avatar Nov 03 '23 12:11 adam-fowler