Replies: 5 comments
|
This is being moved to |
|
Body updated with the current status and root cause: |
|
Cross-linking: #189 (Network Reachability) was closed as a duplicate of this discussion. Reachability and the 3 blocked capability flags here share the same underlying mechanism on Darwin — |
|
Updating with the final decision: both PRs on |
|
Merged: #295. All 5 fields are implemented — |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Overview
The goal is to add additional settings for requests that respect the capabilities of each device. URLSession is an excellent example of the options available to developers.
allowsCellularAccess: BoolAllows/prevents executing a request using cellular data.
allowsExpensiveNetworkAccess: BoolAllows/prevents executing a request on a network interface labeled by the operating system as expensive.
allowsConstrainedNetworkAccess: BoolAllows/prevents executing a request when the data-saving option is active.
waitsForConnectivity: BoolWaits for the device to be connected to the internet before executing the request.
multipathServiceTypeMirrors
NWParameters.multipathServiceType/URLSessionConfiguration.multipathServiceType.Status (2026-08-27) — implemented, merged
All 5 fields are implemented and merged via #295:
allowsCellularAccess,allowsExpensiveNetworkAccess,allowsConstrainedNetworkAccess,waitsForConnectivity— enforced via a pre-flightInternals.NetworkPathGate(Darwin-only, backed byNWPathMonitor), checked once immediately before a request is dispatched on the.nio/.nioTransportServicesexecutors.multipathServiceType— forwards directly to AsyncHTTPClient's existingHTTPClient.Configuration.enableMultipath.URLSessionConfiguration's own defaults (access flags permissive/true,multipathServiceType = .none,waitsForConnectivity = false), and the gate costs nothing for sessions that never touch this API.New public API:
Session.allowsCellularAccess(_:),.allowsExpensiveNetworkAccess(_:),.allowsConstrainedNetworkAccess(_:),.multipathServiceType(_:), plus the existing.waitsForConnectivity(_:)(reimplemented on the same gate — now uniform across every executor instead of NIOTransportServices-only).Note: this shipped on top of
main, independent of the separate, still-in-progress.urlSessionexecutor migration (feature/urlsession-executor) — deliberately, so this win didn't have to wait on that larger effort. When the.urlSessionexecutor lands, these same fields map directly ontoURLSessionConfiguration's native equivalents there, no gate needed on that path — a small, self-contained follow-up at that point, not tracked further here.Why the upstream path is closed
The proposal to add these fields to
HTTPClient.Configurationinswift-server/async-http-clientwas pursued across two PRs:NWParameterssurface. Closed: reviewers felt it overreachedURLSessionConfigurationparity, and that Apple-platform-specific transport tuning belongs inURLSession/Network.frameworkdirectly, or in the emerging cross-platform HTTP client abstraction (apple/swift-http-api-proposal).URLSessionConfigurationequivalent (allowsExpensiveNetworkAccess/allowsConstrainedNetworkAccess). Also closed.There was no remaining path to get these into
HTTPClient.Configuration— RequestDL implemented them on its own instead, as described above.Milestone: 4.2.0
All reactions