@@ -20,6 +20,7 @@ public struct NKSession: Sendable {
2020 public let sessionData : Alamofire . Session
2121 public let sessionDataNoCache : Alamofire . Session
2222 public let sessionDownloadBackground : URLSession
23+ public let sessionDownloadBackgroundExt : URLSession
2324 public let sessionUploadBackground : URLSession
2425 public let sessionUploadBackgroundWWan : URLSession
2526 public let sessionUploadBackgroundExt : URLSession
@@ -47,10 +48,10 @@ public struct NKSession: Sendable {
4748 self . httpMaximumConnectionsPerHostInUpload = httpMaximumConnectionsPerHostInUpload
4849
4950 let backgroundSessionDelegate = NKBackground ( nkCommonInstance: nkCommonInstance)
50- /// Strange but works ?!?!
51+ // Strange but works ?!?!
5152 let sharedCookieStorage = user + " @ " + urlBase
5253
53- /// SessionData Alamofire
54+ // SessionData Alamofire
5455 let configurationSessionData = URLSessionConfiguration . af. default
5556 configurationSessionData. requestCachePolicy = . useProtocolCachePolicy
5657 configurationSessionData. httpMaximumConnectionsPerHost = httpMaximumConnectionsPerHost
@@ -67,7 +68,7 @@ public struct NKSession: Sendable {
6768 serializationQueue: nkCommonInstance. serializationQueue,
6869 eventMonitors: [ NKMonitor ( nkCommonInstance: nkCommonInstance) ] )
6970
70- /// SessionDataNoCache Alamofire
71+ // SessionDataNoCache Alamofire
7172 let configurationSessionDataNoCache = URLSessionConfiguration . af. default
7273 configurationSessionDataNoCache. requestCachePolicy = . reloadIgnoringLocalAndRemoteCacheData
7374 configurationSessionDataNoCache. httpMaximumConnectionsPerHost = httpMaximumConnectionsPerHost
@@ -80,7 +81,7 @@ public struct NKSession: Sendable {
8081 serializationQueue: nkCommonInstance. serializationQueue,
8182 eventMonitors: [ NKMonitor ( nkCommonInstance: nkCommonInstance) ] )
8283
83- /// Session Download Background
84+ // Session Download Background
8485 let configurationDownloadBackground = URLSessionConfiguration . background ( withIdentifier: NKCommon ( ) . getSessionConfigurationIdentifier ( NKCommon ( ) . identifierSessionDownloadBackground, account: account) )
8586 configurationDownloadBackground. allowsCellularAccess = true
8687
@@ -99,7 +100,27 @@ public struct NKSession: Sendable {
99100 configurationDownloadBackground. httpCookieStorage = HTTPCookieStorage . sharedCookieStorage ( forGroupContainerIdentifier: sharedCookieStorage)
100101 sessionDownloadBackground = URLSession ( configuration: configurationDownloadBackground, delegate: backgroundSessionDelegate, delegateQueue: OperationQueue . main)
101102
102- /// Session Upload Background
103+ // Session Download Background Extension
104+ let configurationDownloadBackgroundExt = URLSessionConfiguration . background ( withIdentifier: NKCommon ( ) . identifierSessionDownloadBackgroundExt + UUID( ) . uuidString)
105+ configurationDownloadBackgroundExt. allowsCellularAccess = true
106+
107+ if #available( macOS 11 , * ) {
108+ configurationDownloadBackgroundExt. sessionSendsLaunchEvents = true
109+ }
110+
111+ configurationDownloadBackgroundExt. isDiscretionary = false
112+ configurationDownloadBackgroundExt. httpMaximumConnectionsPerHost = self . httpMaximumConnectionsPerHostInDownload
113+ configurationDownloadBackgroundExt. requestCachePolicy = . useProtocolCachePolicy
114+ configurationDownloadBackgroundExt. sharedContainerIdentifier = groupIdentifier
115+
116+ #if os(iOS) || targetEnvironment(macCatalyst)
117+ configurationDownloadBackgroundExt. multipathServiceType = . handover
118+ #endif
119+
120+ configurationDownloadBackgroundExt. httpCookieStorage = HTTPCookieStorage . sharedCookieStorage ( forGroupContainerIdentifier: sharedCookieStorage)
121+ sessionDownloadBackgroundExt = URLSession ( configuration: configurationDownloadBackgroundExt, delegate: backgroundSessionDelegate, delegateQueue: OperationQueue . main)
122+
123+ // Session Upload Background
103124 let configurationUploadBackground = URLSessionConfiguration . background ( withIdentifier: NKCommon ( ) . getSessionConfigurationIdentifier ( NKCommon ( ) . identifierSessionUploadBackground, account: account) )
104125 configurationUploadBackground. allowsCellularAccess = true
105126
@@ -118,7 +139,7 @@ public struct NKSession: Sendable {
118139 configurationUploadBackground. httpCookieStorage = HTTPCookieStorage . sharedCookieStorage ( forGroupContainerIdentifier: sharedCookieStorage)
119140 sessionUploadBackground = URLSession ( configuration: configurationUploadBackground, delegate: backgroundSessionDelegate, delegateQueue: OperationQueue . main)
120141
121- /// Session Upload Background WWan
142+ // Session Upload Background WWan
122143 let configurationUploadBackgroundWWan = URLSessionConfiguration . background ( withIdentifier: NKCommon ( ) . getSessionConfigurationIdentifier ( NKCommon ( ) . identifierSessionUploadBackgroundWWan, account: account) )
123144 configurationUploadBackgroundWWan. allowsCellularAccess = false
124145
@@ -132,7 +153,7 @@ public struct NKSession: Sendable {
132153 configurationUploadBackgroundWWan. httpCookieStorage = HTTPCookieStorage . sharedCookieStorage ( forGroupContainerIdentifier: sharedCookieStorage)
133154 sessionUploadBackgroundWWan = URLSession ( configuration: configurationUploadBackgroundWWan, delegate: backgroundSessionDelegate, delegateQueue: OperationQueue . main)
134155
135- /// Session Upload Background Extension
156+ // Session Upload Background Extension
136157 let configurationUploadBackgroundExt = URLSessionConfiguration . background ( withIdentifier: NKCommon ( ) . identifierSessionUploadBackgroundExt + UUID( ) . uuidString)
137158 configurationUploadBackgroundExt. allowsCellularAccess = true
138159
0 commit comments