networking with nsurlsession - apple inc. · 2016. 7. 8. · nsurlsession api for downloading http...
TRANSCRIPT
© 2015 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.
#WWDC15
Networking with NSURLSession
Luke Case Software EngineerAndreas Garkuscha Software EngineerDan Vinegrad Software Engineer
System Frameworks
Session 711
App Transport Security
New protocol support in NSURLSession
NSURLSession on watchOS
NSURLSession API changes
NSURLSession
API for downloading HTTP contentRich set of delegate methodsBackground download/upload capability
HTTP(cleartext)
HTTP(cleartext)
GET
HTTP/1.1 200 OK
HTTP(cleartext)
HTTP(cleartext)
HTTP(cleartext)
HTTPS
HTTPS
HTTPSHTTP over TLS
EncryptionIntegrityAuthentication
Protecting Customer DataHTTPS: securing HTTP with TLS
"http://" to "https://"Server support requiredWidespread support availableAll data is sensitive
App Transport Security
Protecting Customer DataWhat is App Transport Security (ATS)?
Disallows cleartext HTTP URL loadsEncourages best practice secure connectionsDefaults to stronger securityAllows configuration via app's Info.plist
HTTPS
NSAppTransportSecurity NSExceptionDomains "example.com" NSIncludesSubdomains = YES NSExceptionRequiresForwardSecrecy = NO NSExceptionMinimumTLSVersion = "TLSv1.1"
HTTPS
HTTPS
MediaServer
NSAppTransportSecurity NSExceptionDomains "media.example.com" NSExceptionAllowsInsecureHTTPLoads = YES
NSAppTransportSecurity NSAllowsArbitraryLoads = YES
Server
NSAppTransportSecurity NSAllowsArbitraryLoads NSExceptionDomains "secure.example.com" NSExceptionAllowsInsecureHTTPLoads = NO
Configuring ATSDiagnosing issues
Active when you build your app for iOS 9 and OS X El Capitan"http://" to "https://" is automaticUse NSAllowsArbitraryLoads for quick triage Log NSURLSession errorsCFNETWORK_DIAGNOSTICS=1
Protecting Customer DataNext steps
Use HTTPS for new projectsTransition existing apps from HTTP to HTTPSUse exceptions where needed
New Protocol Support in NSURLSession
Andreas GarkuschaSoftware Engineer
New in NSURLSession
New in NSURLSession
HTTP/2RFC 7540
New in NSURLSession
HTTP/2RFC 7540
New in NSURLSession
New in NSURLSession
New in NSURLSession
HTTP/2RFC 7540
Future of the Web
Major milestonein the evolutionof the Web
Makes the Web
fasterSolves HTTP/1.1problems
HTTP/2 in NSURLSession
Why a new protocol?HTTP/2 in depthAdoption using NSURLSession
Why a New Protocol?
Why a New Protocol?
Why a New Protocol?
FTP HTTP POP3 LDAP RTP
SMTP NTP TCP IMAP UDP
ARP SNMP PPP SOAP ICMP
IP APX Telnet RADIUS VNC
SSH VoIP AFP smb nfsDHCP SKYPE RDP WebSocket RIP
AIM Bonjour ICQ QUAKE3 …
Why a New Protocol?
FTP HTTP POP3 LDAP RTP
SMTP NTP TCP IMAP UDP
ARP SNMP PPP SOAP ICMP
IP APX Telnet RADIUS VNC
SSH VoIP AFP smb nfsDHCP SKYPE RDP WebSocket RIP
AIM Bonjour ICQ QUAKE3 …
Why a New Protocol?
HTTP/1.1 Common Issues
HTTP/1.1Common issues
One outstanding request
HTTP/1.1Common issues
One outstanding requestHTTP pipelining
HTTP/1.1Common issues
One outstanding requestHTTP pipeliningMultiple connections
HTTP/1.1Common issues
One outstanding requestHTTP pipeliningMultiple connectionsTextual protocol overhead
HTTP/1.1Common issues
One outstanding requestHTTP pipeliningMultiple connectionsTextual protocol overheadHeader compression
The Path to HTTP/2
Experimental protocolsSpecification for HTTP/2IETF standardization, RFC
New in NSURLSession
New in NSURLSession
HTTP/2RFC 7540
HTTP/1.1 HTTP/2
HTTP/1.1 HTTP/2
Multiple TCP connections to a host Only one TCP connection
HTTP/1.1 HTTP/2
Multiple TCP connections to a host Only one TCP connection
Head-of-line blocking Fully multiplexed
HTTP/1.1 HTTP/2
Multiple TCP connections to a host Only one TCP connection
Head-of-line blocking Fully multiplexed
FIFO restrictions Requests have priorities
HTTP/2 - MultiplexingSolution for Head-of-Line Blocking problem
Time
HTTP/1.1: Head-of-Line Blocking
HTTP/2: Multiplexing
Priority LegendLow
Medium
High
(without Pipelining)
HTTP/2 - MultiplexingSolution for Head-of-Line Blocking problem
Time
HTTP/1.1: Head-of-Line Blocking
HTTP/2: Multiplexing
Priority LegendLow
Medium
High
image.jpg
styles.css
data.xml
(without Pipelining)
HTTP/2 - MultiplexingSolution for Head-of-Line Blocking problem
Time
HTTP/1.1: Head-of-Line Blocking
HTTP/2: Multiplexing
Priority LegendLow
Medium
High
image.jpg
styles.css
data.xml
GET
(without Pipelining)
200 OK
HTTP/2 - MultiplexingSolution for Head-of-Line Blocking problem
Time
HTTP/1.1: Head-of-Line Blocking
HTTP/2: Multiplexing
Priority LegendLow
Medium
High
image.jpg
styles.css
data.xml
✔GET
(without Pipelining)
HTTP/2 - MultiplexingSolution for Head-of-Line Blocking problem
Time
HTTP/1.1: Head-of-Line Blocking
HTTP/2: Multiplexing
Priority LegendLow
Medium
High
image.jpg
styles.css
data.xml
✔
✔
(without Pipelining)
HTTP/2 - MultiplexingSolution for Head-of-Line Blocking problem
Time
HTTP/1.1: Head-of-Line Blocking
HTTP/2: Multiplexing
Priority LegendLow
Medium
High
image.jpg
styles.css
data.xml
✔
✔
✔
(without Pipelining)
HTTP/2 - MultiplexingSolution for Head-of-Line Blocking problem
Time
HTTP/1.1: Head-of-Line Blocking
HTTP/2: Multiplexing
image.jpg
styles.css
data.xml
✔
✔
✔
(without Pipelining)
Priority LegendLow
Medium
High
HTTP/2 - MultiplexingSolution for Head-of-Line Blocking problem
Time
HTTP/1.1: Head-of-Line Blocking
HTTP/2: Multiplexing
image.jpg
styles.css
data.xml
✔
✔
✔
(with Pipelining)
Priority LegendLow
Medium
High
HTTP/2 - MultiplexingSolution for Head-of-Line Blocking problem
Time
HTTP/2: Multiplexing
image.jpg
styles.css
data.xml
✔
✔
✔
HTTP/1.1: Head-of-Line Blocking (with Pipelining)
Priority LegendLow
Medium
High
HTTP/2 - MultiplexingSolution for Head-of-Line Blocking problem
Time
HTTP/2: Multiplexing
image.jpg
styles.css
data.xml
image.jpg
styles.css
data.xml
✔
✔
✔
HTTP/1.1: Head-of-Line Blocking (with Pipelining)
Priority LegendLow
Medium
High
HTTP/2 - MultiplexingSolution for Head-of-Line Blocking problem
Time
HTTP/2: Multiplexing
image.jpg
styles.css
data.xml
image.jpg
styles.css
data.xml
✔
✔
✔
HTTP/1.1: Head-of-Line Blocking (with Pipelining)
Priority LegendLow
Medium
High
HTTP/2 - MultiplexingSolution for Head-of-Line Blocking problem
Time
HTTP/2: Multiplexing
image.jpg
styles.css
data.xml
image.jpg
styles.css
data.xml
✔
✔
✔
HTTP/1.1: Head-of-Line Blocking (with Pipelining)
Priority LegendLow
Medium
High
HTTP/2 - MultiplexingSolution for Head-of-Line Blocking problem
Time
HTTP/2: Multiplexing
image.jpg
styles.css
data.xml
image.jpg
styles.css
data.xml
✔
✔
✔
HTTP/1.1: Head-of-Line Blocking (with Pipelining)
Priority LegendLow
Medium
High
HTTP/2 - MultiplexingSolution for Head-of-Line Blocking problem
Time
HTTP/2: Multiplexing
image.jpg
styles.css
data.xml
image.jpg
styles.css
data.xml
✔
✔
✔
✔
✔
HTTP/1.1: Head-of-Line Blocking
✔
(with Pipelining)
Priority LegendLow
Medium
High
HTTP/1.1 HTTP/2
Multiple TCP connections to a host Only one TCP connection
Head-of-line blocking Fully multiplexed
FIFO restrictions Requests have priorities
HTTP/1.1 HTTP/2
Multiple TCP connections to a host Only one TCP connection
Head-of-line blocking Fully multiplexed
FIFO restrictions Requests have priorities
Textual protocol overhead Binary
HTTP/1.1 HTTP/2
Multiple TCP connections to a host Only one TCP connection
Head-of-line blocking Fully multiplexed
FIFO restrictions Requests have priorities
Textual protocol overhead Binary
No header compression Header compression (HPACK)
Index Header Name Header Value-
HTTP/2 Header Compression
Index Header Name Header Value1 :authority2 :method GET3 :method POST4 :path /5 :path /index.html6 :scheme http7 :scheme https8 :status 200
… …14 :status 50015 accept-charset16 accept-encoding gzip, deflate17 accept-language… …57 transfer-encoding58 user-agent59 vary60 via61 www-authenticate
HPACK Static Table Dynamic Table
Index Header Name Header Value-
HTTP/2 Header CompressionHPACK Static Table
Index Header Name Header Value1 :authority2 :method GET3 :method POST4 :path /5 :path /index.html6 :scheme http7 :scheme https8 :status 200
… …14 :status 50015 accept-charset16 accept-encoding gzip, deflate17 accept-language… …57 transfer-encoding58 user-agent59 vary60 via61 www-authenticate
Dynamic Table
Index Header Name Header Value-
HTTP/2 Header CompressionHPACK Static Table
Index Header Name Header Value1 :authority2 :method GET3 :method POST4 :path /5 :path /index.html6 :scheme http7 :scheme https8 :status 200
… …14 :status 50015 accept-charset16 accept-encoding gzip, deflate17 accept-language… …57 transfer-encoding58 user-agent59 vary60 via61 www-authenticate
Dynamic Table
GET / HTTP/1.1\r\n Host: www.example.com\r\n Connection: Keep-Alive\r\n\r\n
HTTP/1.1 Request:
Index Header Name Header Value-
HTTP/2 Header CompressionHPACK Static Table
Index Header Name Header Value1 :authority2 :method GET3 :method POST4 :path /5 :path /index.html6 :scheme http7 :scheme https8 :status 200
… …14 :status 50015 accept-charset16 accept-encoding gzip, deflate17 accept-language… …57 transfer-encoding58 user-agent59 vary60 via61 www-authenticate
Dynamic Table
:method: GET :scheme: https :path: / :authority: www.example.com
HTTP/2 Representation:
GET / HTTP/1.1\r\n Host: www.example.com\r\n Connection: Keep-Alive\r\n\r\n
HTTP/1.1 Request:
Index Header Name Header Value-
HTTP/2 Header CompressionHPACK Static Table
Index Header Name Header Value1 :authority2 :method GET3 :method POST4 :path /5 :path /index.html6 :scheme http7 :scheme https8 :status 200
… …14 :status 50015 accept-charset16 accept-encoding gzip, deflate17 accept-language… …57 transfer-encoding58 user-agent59 vary60 via61 www-authenticate
Dynamic Table
:method: GET :scheme: https :path: / :authority: www.example.com
HTTP/2 Representation:
GET / HTTP/1.1\r\n Host: www.example.com\r\n Connection: Keep-Alive\r\n\r\n
HTTP/1.1 Request:
Index Header Name Header Value-
HTTP/2 Header CompressionHPACK Static Table
Index Header Name Header Value1 :authority2 :method GET3 :method POST4 :path /5 :path /index.html6 :scheme http7 :scheme https8 :status 200
… …14 :status 50015 accept-charset16 accept-encoding gzip, deflate17 accept-language… …57 transfer-encoding58 user-agent59 vary60 via61 www-authenticate
Dynamic Table
:method: GET :scheme: https :path: / :authority: www.example.com
HTTP/2 Representation:
GET / HTTP/1.1\r\n Host: www.example.com\r\n Connection: Keep-Alive\r\n\r\n
HTTP/1.1 Request:
Index Header Name Header Value-
HTTP/2 Header CompressionHPACK Static Table
Index Header Name Header Value1 :authority2 :method GET3 :method POST4 :path /5 :path /index.html6 :scheme http7 :scheme https8 :status 200
… …14 :status 50015 accept-charset16 accept-encoding gzip, deflate17 accept-language… …57 transfer-encoding58 user-agent59 vary60 via61 www-authenticate
Dynamic Table
:method: GET :scheme: https :path: / :authority: www.example.com
HTTP/2 Representation:
GET / HTTP/1.1\r\n Host: www.example.com\r\n Connection: Keep-Alive\r\n\r\n
HTTP/1.1 Request:
Index Header Name Header Value-
HTTP/2 Header CompressionHPACK Static Table
Index Header Name Header Value1 :authority2 :method GET3 :method POST4 :path /5 :path /index.html6 :scheme http7 :scheme https8 :status 200
… …14 :status 50015 accept-charset16 accept-encoding gzip, deflate17 accept-language… …57 transfer-encoding58 user-agent59 vary60 via61 www-authenticate
Dynamic Table
:method: GET :scheme: https :path: / :authority: www.example.com
HTTP/2 Representation:
GET / HTTP/1.1\r\n Host: www.example.com\r\n Connection: Keep-Alive\r\n\r\n
HTTP/1.1 Request:
Index Header Name Header Value-
HTTP/2 Header Compression
Index Header Name Header Value1 :authority2 :method GET3 :method POST4 :path /5 :path /index.html6 :scheme http7 :scheme https8 :status 200
… …14 :status 50015 accept-charset16 accept-encoding gzip, deflate17 accept-language… …57 transfer-encoding58 user-agent59 vary60 via61 www-authenticate
:method: GET :scheme: https :path: / :authority: www.example.com
HTTP/2 Representation:
GET / HTTP/1.1\r\n Host: www.example.com\r\n Connection: Keep-Alive\r\n\r\n
HTTP/1.1 Request:
HPACK Static Table Dynamic Table
Index Header Name Header Value-
HTTP/2 Header Compression
Index Header Name Header Value1 :authority2 :method GET3 :method POST4 :path /5 :path /index.html6 :scheme http7 :scheme https8 :status 200
… …14 :status 50015 accept-charset16 accept-encoding gzip, deflate17 accept-language… …57 transfer-encoding58 user-agent59 vary60 via61 www-authenticate
:method: GET :scheme: https :path: / :authority: www.example.com
HTTP/2 Representation:
GET / HTTP/1.1\r\n Host: www.example.com\r\n Connection: Keep-Alive\r\n\r\n
HTTP/1.1 Request:
www.example.com
HPACK Static Table Dynamic Table
Index Header Name Header Value1 :authority www.example.com
HTTP/2 Header Compression
Index Header Name Header Value1 :authority2 :method GET3 :method POST4 :path /5 :path /index.html6 :scheme http7 :scheme https8 :status 200
… …14 :status 50015 accept-charset16 accept-encoding gzip, deflate17 accept-language… …57 transfer-encoding58 user-agent59 vary60 via61 www-authenticate
HPACK Static Table Dynamic Table
Index Header Name Header Value1 :authority www.example.com
HTTP/2 Header Compression
Index Header Name Header Value1 :authority2 :method GET3 :method POST4 :path /5 :path /index.html6 :scheme http7 :scheme https8 :status 200
… …14 :status 50015 accept-charset16 accept-encoding gzip, deflate17 accept-language… …57 transfer-encoding58 user-agent59 vary60 via61 www-authenticate
HPACK Static Table Dynamic Table
Index Header Name Header Value1 :authority www.example.com
HTTP/2 Header Compression
Index Header Name Header Value1 :authority2 :method GET3 :method POST4 :path /5 :path /index.html6 :scheme http7 :scheme https8 :status 200
… …14 :status 50015 accept-charset16 accept-encoding gzip, deflate17 accept-language… …57 transfer-encoding58 user-agent59 vary60 via61 www-authenticate
GET /index.html HTTP/1.1\r\n Host: www.example.com\r\n Connection: Keep-Alive\r\n\r\n
HTTP/1.1 Second request:
HPACK Static Table Dynamic Table
Index Header Name Header Value1 :authority www.example.com
HTTP/2 Header Compression
Index Header Name Header Value1 :authority2 :method GET3 :method POST4 :path /5 :path /index.html6 :scheme http7 :scheme https8 :status 200
… …14 :status 50015 accept-charset16 accept-encoding gzip, deflate17 accept-language… …57 transfer-encoding58 user-agent59 vary60 via61 www-authenticate
GET /index.html HTTP/1.1\r\n Host: www.example.com\r\n Connection: Keep-Alive\r\n\r\n
HTTP/1.1 Second request:
HTTP/2 Second request::method: GET :scheme: https :path: /index.html :authority: www.example.com
HPACK Static Table Dynamic Table
Index Header Name Header Value1 :authority www.example.com
HTTP/2 Header Compression
Index Header Name Header Value1 :authority2 :method GET3 :method POST4 :path /5 :path /index.html6 :scheme http7 :scheme https8 :status 200
… …14 :status 50015 accept-charset16 accept-encoding gzip, deflate17 accept-language… …57 transfer-encoding58 user-agent59 vary60 via61 www-authenticate
GET /index.html HTTP/1.1\r\n Host: www.example.com\r\n Connection: Keep-Alive\r\n\r\n
HTTP/1.1 Second request:
HTTP/2 Second request:☐☐☐☐
HPACK Static Table Dynamic Table
HTTP/2 Adoption on the client
NSURLSession supports HTTP/2 protocol automatically
HTTP/2 Adoption on the client
NSURLSession supports HTTP/2 protocol automaticallyNo source code changes needed
HTTP/2 Adoption on the client
NSURLSession supports HTTP/2 protocol automaticallyNo source code changes needed
HTTP/2 Adoption on the client
let sessionConfig = NSURLSessionConfiguration.defaultSessionConfiguration() let session = NSURLSession(configuration: sessionConfig)
let url = NSURL(string: "https://www.example.com")! let task = session.dataTaskWithURL(url) { (data: NSData?, response: NSURLResponse?, error: NSError?) in ... }
task?.resume()
You Only Need an HTTP/2 Server
HTTP/2 in NSURLSessionCompatibility
Backward compatible with HTTP/1.1 serversEncrypted connection onlyHTTP/2 server requires ALPN or NPN support
HTTP/2 TodayCurrent adoption
HomeKit Remote Access via iCloudServices provided by Google and TwitterOpen source web serversContent Delivery Network providers
HTTP/2At a glance
HTTP/2 is available in WWDC seed todayAvailable in NSURLSessionEnabled in Safari on OS X 10.11 and iOS 9
NSURLSession on watchOS
Dan VinegradSoftware Engineer
NSURLSession on watchOS
Fully supported for HTTP(S)Uses best available connectivity (iPhone or WiFi)
NSURLSession on watchOS
Fully supported for HTTP(S)Uses best available connectivity (iPhone or WiFi)It’s Magic
NSURLSession on watchOSBest practices
NSURLSession on watchOSBest practices
Download the minimal assets required• Small screen• Limited bandwidth
NSURLSession on watchOSBest practices
Download the minimal assets required• Small screen• Limited bandwidth
Apps will only run for a very short time• Send small amounts of data• Use background uploads/downloads for larger content
API Changes
NSURLConnection
NSURLConnection
Deprecated in OS X 10.11 and iOS 9.0• Not going away, apps using it will still work• New features will be added to NSURLSession
Not supported on watchOSSwitching to NSURLSession is easy
Switching to NSURLSession
let queue: NSOperationQueue = ... let url = NSURL(string: "https://www.example.com")! let request = NSURLRequest(URL: url)
NSURLConnection.sendAsynchronousRequest(request, queue: queue) { (response: NSURLResponse?, data: NSData?, error: NSError?) in ... }
Switching to NSURLSession
let queue: NSOperationQueue = ... let url = NSURL(string: "https://www.example.com")! let request = NSURLRequest(URL: url)
NSURLConnection.sendAsynchronousRequest(request, queue: queue) { (response: NSURLResponse?, data: NSData?, error: NSError?) in ... }
let task = NSURLSession.sharedSession().dataTaskWithRequest(request) { (data: NSData?, response: NSURLResponse?, error: NSError?) in
... } task?.resume()
New NSURLSession API
Sharing CookiesBetween Apps and Extensions
Apps and their extensions have different cookie storages by defaultCan use application groups to get a shared data containerOS X 10.11 and iOS 9 introduce new API to create a shared cookie storage
New NSHTTPCookieStorage API
let ident = "group.mycompany.mygroupname" let cookieStorage = NSHTTPCookieStorage.sharedCookieStorageForGroupContainerIdentifier( identifier: ident)
let config = NSURLSessionConfiguration.defaultSessionConfiguration() config.HTTPCookieStorage = cookieStorage let session = NSURLSession(configuration: config)
NSURLSessionStreamTaskTCP/IP networking
NSURLSessionStreamTaskTCP/IP networking
Sometimes need a protocol other than HTTP(S)
NSURLSessionStreamTaskTCP/IP networking
Sometimes need a protocol other than HTTP(S)Advantages over NSInputStream / NSOutputStream• Asynchronous read/write interface• Can automatically get through HTTP proxies• New API goodies
NSURLSessionStreamTaskTCP/IP networking
Sometimes need a protocol other than HTTP(S)Advantages over NSInputStream / NSOutputStream• Asynchronous read/write interface• Can automatically get through HTTP proxies• New API goodies
Legacy NSStream support
NSURLSessionStreamTaskTCP/IP networking
NSURLSessionStreamTaskTCP/IP networking
Supports TCP/IP connections:• Hostname and port• NSNetService resolution
NSURLSessionStreamTaskTCP/IP networking
Supports TCP/IP connections:• Hostname and port• NSNetService resolution
Uses existing NSURLSession configuration and session delegates
NSURLSessionStreamTaskTCP/IP networking
Supports TCP/IP connections:• Hostname and port• NSNetService resolution
Uses existing NSURLSession configuration and session delegatesSecure TLS connections supported• Even after connected!
NSURLSessionStreamTaskAsynchronous read
let task = NSURLSession.sharedSession().streamTaskWithHostName("chat.example.com",
port: 5555)! task.resume() task.readDataOfMinLength(16384, maxLength:65536, timeout: 30.0) { (data: NSData?, eof: Bool, error: NSError?) in ... }
NSURLSessionStreamTaskAsynchronous write
let task = NSURLSession.sharedSession().streamTaskWithHostName("chat.example.com",
port: 5555)! task.resume() let data: NSData = ... task.writeData(data, timeout: 30.0) { (error: NSError?) in ... }
NSURLSessionStreamTaskEnabling TLS
let task = NSURLSession.sharedSession().streamTaskWithHostName("chat.example.com",
port: 5555)! task.startSecureConnection() task.resume() let data: NSData = ... task.writeData(data, timeout: 30.0) { (error: NSError?) in ... }
NSURLSessionStreamTaskConversion to NSStreams
NSURLSessionStreamTaskConversion to NSStreams
Some existing APIs consume NSStream objects
NSURLSessionStreamTaskConversion to NSStreams
Some existing APIs consume NSStream objectsPending reads/writes complete before NSStreams are produced
NSURLSessionStreamTaskConversion to NSStreams
Some existing APIs consume NSStream objectsPending reads/writes complete before NSStreams are producedDetaches the task from the session
NSURLSessionStreamTaskNSStream support
let streamTask: NSURLSessionStreamTask = …
streamTask.captureStreams()
NSURLSessionStreamTaskNSStream support
func URLSession(session: NSURLSession,streamTask: NSURLSessionStreamTask, didBecomeInputStream inputStream: NSInputStream, outputStream: NSOutputStream) {
// Can pass inputStream / outputStream to APIs that consume NSStreams
}
NSURLSessionStreamTaskOther (informational) delegate methods
optional func URLSession(session: NSURLSession, betterRouteDiscoveredForStreamTaskstreamTask: NSURLSessionStreamTask)
NSURLSessionStreamTaskOther (informational) delegate methods
optional func URLSession(session: NSURLSession, betterRouteDiscoveredForStreamTask streamTask: NSURLSessionStreamTask)
optional func URLSession(session: NSURLSession, readClosedForStreamTask streamTask: NSURLSessionStreamTask)
optional func URLSession(session: NSURLSession, writeClosedForStreamTask streamTask: NSURLSessionStreamTask)
NSURLSessionStreamTaskDataTask conversion
NSURLSessionStreamTaskDataTask conversion
NSURLSessionDataTask may be converted to a stream task• Use NSURLSession to get through HTTP proxies
NSURLSessionStreamTaskDataTask conversion
NSURLSessionDataTask may be converted to a stream task• Use NSURLSession to get through HTTP proxies
Conversion can occur when response is received
NSURLSessionStreamTaskDataTask conversion
func URLSession(session: NSURLSession, dataTask: NSURLSessionDataTask, didReceiveResponse response: NSURLResponse, completionHandler: (NSURLSessionResponseDisposition) -> Void) {
completionHandler(.BecomeStream) }
func URLSession(session: NSURLSession, dataTask: NSURLSessionDataTask, didBecomeStreamTask streamTask: NSURLSessionStreamTask) {
}
Summary
App Transport SecurityHTTP/2 support in NSURLSessionNSURLSession on watchOSNSURLConnection deprecationNew API• Group container cookie storages• NSURLSessionStreamTask
More Information
DocumentationDeveloper Resourceshttps://developer.apple.com
Technical SupportApple Developer Forumshttp://devforums.apple.com
Developer Technical Supporthttp://developer.apple.com/support/technical
General InquiriesPaul Danbold, Core OS [email protected]
Related Sessions
Security and Your Apps Mission Tuesday 4:30PM
Introducing Watch Connectivity Pacific Heights Thursday 11:00AM
Your App and Next Generation Networks Mission Friday 11:00AM
Related Labs
Networking Lab Frameworks Lab E Thursday 10:00AM
Networking Lab Frameworks Lab B Friday 1:30PM