In wwdc viedo [[networking with nsurlsession]], they say NSURLSession supports HTTP/2 protocol automatically;
but when i use this code,
let sessionConfig = NSURLSessionConfiguration.defaultSessionConfiguration()
let session = NSURLSession(configuration: sessionConfig)
let url = NSURL(string: "https://www.google.com.hk")
let task = session.dataTaskWithURL(url) {
(data: NSData?, response: NSURLResponse?, error: NSError?) in
...
}
task?.resume()
it does not use HTTP/2.
But with this code ,it's just ok
let session = NSURLSession.sharedSession()
let url = NSURL(string: "https://www.google.com.hk")
let task = session.dataTaskWithURL(url) {
(data: NSData?, response: NSURLResponse?, error: NSError?) in
...
}
task?.resume()
The network is ok, it uses http/2
Anybody who knows why?