Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Registered Protocols Not Loaded For Default URLSessionConfiguration Initialization #4940

Open
brianmichel opened this issue Apr 24, 2024 · 0 comments
Assignees

Comments

@brianmichel
Copy link

There is a long standing crash when using URLSession #4791 that could more easily be worked around if URLSessionConfiguration initializers used URLProtocol.getProtocols() to populate the list of protocols to check on this object instead of a static list of [_HTTPURLProtocol.self, _FTPURLProtocol.self, _WebSocketURLProtocol.self].

Querying the URLProtocol system for the registered set of protocols would provide a safe route for Swift developers on non-Darwin systems to reimplement URL loading (if they choose to) for all 3rd party dependencies that they might pull in. Using the existing URLProtocol system would be less invasive than forking every dependency and patching in a different networking stack while maintaining cross platform compatibility.

Currently the docs about URLSessionConfiguration (https://developer.apple.com/documentation/foundation/urlsessionconfiguration) doesn't make mention about how the URLProtocol registration system factors into what gets used when you create a new instance of URLSessionConfiguration. The only relevant comments I can see are regarding the protocolClasses property which indicate extra protocols to use, but not how registered protocols factor into this API.

There is additional confusion that the built in protocols don't seem to show up in the protocolClasses array when using URLSessionConfiguration.default but are clearly still used since network requests can be made.

This patch set could be consistency in usage with what URLProtocols are available and used in all situations for URLSession.

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

No branches or pull requests

2 participants