@@ -1489,7 +1489,8 @@ public class NSURLSessionConfiguration : NSObject, NSCopying {
1489
1489
super. init ( )
1490
1490
}
1491
1491
1492
- private init ( requestCachePolicy: NSURLRequestCachePolicy ,
1492
+ private init ( identifier: String ? ,
1493
+ requestCachePolicy: NSURLRequestCachePolicy ,
1493
1494
timeoutIntervalForRequest: NSTimeInterval ,
1494
1495
timeoutIntervalForResource: NSTimeInterval ,
1495
1496
networkServiceType: NSURLRequestNetworkServiceType ,
@@ -1503,8 +1504,11 @@ public class NSURLSessionConfiguration : NSObject, NSCopying {
1503
1504
HTTPMaximumConnectionsPerHost: Int ,
1504
1505
HTTPCookieStorage: NSHTTPCookieStorage ? ,
1505
1506
URLCredentialStorage: NSURLCredentialStorage ? ,
1506
- URLCache: NSURLCache ? )
1507
+ URLCache: NSURLCache ? ,
1508
+ shouldUseExtendedBackgroundIdleMode: Bool ,
1509
+ protocolClasses: [ AnyClass ] ? )
1507
1510
{
1511
+ self . identifier = identifier
1508
1512
self . requestCachePolicy = requestCachePolicy
1509
1513
self . timeoutIntervalForRequest = timeoutIntervalForRequest
1510
1514
self . timeoutIntervalForResource = timeoutIntervalForResource
@@ -1520,11 +1524,17 @@ public class NSURLSessionConfiguration : NSObject, NSCopying {
1520
1524
self . HTTPCookieStorage = HTTPCookieStorage
1521
1525
self . URLCredentialStorage = URLCredentialStorage
1522
1526
self . URLCache = URLCache
1523
- self . shouldUseExtendedBackgroundIdleMode = false
1527
+ self . shouldUseExtendedBackgroundIdleMode = shouldUseExtendedBackgroundIdleMode
1528
+ self . protocolClasses = protocolClasses
1524
1529
}
1525
1530
1526
1531
public override func copy( ) -> AnyObject {
1532
+ return copyWithZone ( nil )
1533
+ }
1534
+
1535
+ public func copyWithZone( zone: NSZone ) -> AnyObject {
1527
1536
return NSURLSessionConfiguration (
1537
+ identifier: identifier,
1528
1538
requestCachePolicy: requestCachePolicy,
1529
1539
timeoutIntervalForRequest: timeoutIntervalForRequest,
1530
1540
timeoutIntervalForResource: timeoutIntervalForResource,
@@ -1539,11 +1549,9 @@ public class NSURLSessionConfiguration : NSObject, NSCopying {
1539
1549
HTTPMaximumConnectionsPerHost: HTTPMaximumConnectionsPerHost,
1540
1550
HTTPCookieStorage: HTTPCookieStorage,
1541
1551
URLCredentialStorage: URLCredentialStorage,
1542
- URLCache: URLCache)
1543
- }
1544
-
1545
- public func copyWithZone( zone: NSZone ) -> AnyObject {
1546
- NSUnimplemented ( )
1552
+ URLCache: URLCache,
1553
+ shouldUseExtendedBackgroundIdleMode: shouldUseExtendedBackgroundIdleMode,
1554
+ protocolClasses: protocolClasses)
1547
1555
}
1548
1556
1549
1557
public class func defaultSessionConfiguration( ) -> NSURLSessionConfiguration {
@@ -1553,7 +1561,7 @@ public class NSURLSessionConfiguration : NSObject, NSCopying {
1553
1561
public class func backgroundSessionConfigurationWithIdentifier( identifier: String ) -> NSURLSessionConfiguration { NSUnimplemented ( ) }
1554
1562
1555
1563
/* identifier for the background session configuration */
1556
- public var identifier : String ? { NSUnimplemented ( ) }
1564
+ public var identifier : String ?
1557
1565
1558
1566
/* default cache policy for requests */
1559
1567
public var requestCachePolicy : NSURLRequestCachePolicy
@@ -1641,6 +1649,9 @@ public class NSURLSessionConfiguration : NSObject, NSCopying {
1641
1649
1642
1650
internal extension NSURLSession {
1643
1651
struct Configuration {
1652
+ /// identifier for the background session configuration
1653
+ let identifier : String ?
1654
+
1644
1655
/// default cache policy for requests
1645
1656
let requestCachePolicy : NSURLRequestCachePolicy
1646
1657
@@ -1653,6 +1664,12 @@ internal extension NSURLSession {
1653
1664
/// type of service for requests.
1654
1665
let networkServiceType : NSURLRequestNetworkServiceType
1655
1666
1667
+ /// allow request to route over cellular.
1668
+ let allowsCellularAccess : Bool
1669
+
1670
+ /// allows background tasks to be scheduled at the discretion of the system for optimal performance.
1671
+ let discretionary : Bool
1672
+
1656
1673
/// The proxy dictionary, as described by <CFNetwork/CFHTTPStream.h>
1657
1674
let connectionProxyDictionary : [ NSObject : AnyObject ] ?
1658
1675
@@ -1671,20 +1688,42 @@ internal extension NSURLSession {
1671
1688
let HTTPAdditionalHeaders : [ String : String ] ?
1672
1689
/// The maximum number of simultanous persistent connections per host
1673
1690
let HTTPMaximumConnectionsPerHost : Int
1691
+
1692
+ /// The cookie storage object to use, or nil to indicate that no cookies should be handled
1693
+ let HTTPCookieStorage : NSHTTPCookieStorage ?
1694
+
1695
+ /// The credential storage object, or nil to indicate that no credential storage is to be used
1696
+ let URLCredentialStorage : NSURLCredentialStorage ?
1697
+
1698
+ /// The URL resource cache, or nil to indicate that no caching is to be performed
1699
+ let URLCache : NSURLCache ?
1700
+
1701
+ /// Enable extended background idle mode for any tcp sockets created.
1702
+ let shouldUseExtendedBackgroundIdleMode : Bool
1703
+
1704
+ let protocolClasses : [ AnyClass ] ?
1674
1705
}
1675
1706
}
1676
1707
private extension NSURLSession . Configuration {
1677
1708
init ( URLSessionConfiguration config: NSURLSessionConfiguration ) {
1709
+ identifier = config. identifier
1678
1710
requestCachePolicy = config. requestCachePolicy
1679
1711
timeoutIntervalForRequest = config. timeoutIntervalForRequest
1680
1712
timeoutIntervalForResource = config. timeoutIntervalForResource
1681
1713
networkServiceType = config. networkServiceType
1714
+ allowsCellularAccess = config. allowsCellularAccess
1715
+ discretionary = config. discretionary
1682
1716
connectionProxyDictionary = config. connectionProxyDictionary
1683
1717
HTTPShouldUsePipelining = config. HTTPShouldUsePipelining
1684
1718
HTTPShouldSetCookies = config. HTTPShouldSetCookies
1685
1719
HTTPCookieAcceptPolicy = config. HTTPCookieAcceptPolicy
1686
1720
HTTPAdditionalHeaders = config. HTTPAdditionalHeaders. map { convertToStringString ( dictionary: $0) }
1687
1721
HTTPMaximumConnectionsPerHost = config. HTTPMaximumConnectionsPerHost
1722
+ HTTPCookieStorage = config. HTTPCookieStorage
1723
+ URLCredentialStorage = config. URLCredentialStorage
1724
+ URLCache = config. URLCache
1725
+ shouldUseExtendedBackgroundIdleMode = config. shouldUseExtendedBackgroundIdleMode
1726
+ protocolClasses = config. protocolClasses
1688
1727
}
1689
1728
}
1690
1729
0 commit comments