HTTP/2 支持 iOS 8

HTTP/2 support for iOS 8

我尝试了 Xcode 7 Beta + NSURLSession,它已经支持 HTTP/2 并且效果非常好。

现在我想知道,当我发布使用 iOS 9 SDK 构建但支持 iOS 8 的应用程序时 - iOS 8 用户能够使用 HTTP2 吗? 或者它只适用于 iOS 9 ?

我在 Apple Developers Forum 上问过同样的问题,他们给出了 crystal 明确的回答:

The HTTP/2 support is part of iOS 9, and thus won't be available on earlier OS releases.

https://forums.developer.apple.com/message/31667

But what is bothering me is iOS 8 behaviour. I'm still confused by your actual issue. I suspect you're talking about this case:

  1. you build an app using NSURLSession
  2. you deploy a server that supports HTTP/2
  3. on iOS 9, this will talk to your server via HTTP/2
  4. on iOS 8, this will talk to your server via HTTP/1.1 or SPDY
  5. on iOS 7, this will talk to your server via HTTP/1.1

Whether this works really depends on your server. Ignoring iOS 8 and SPDY for the moment, consider the iOS 7 case. Here iOS is simply going to open the connection and send an HTTP command. What does your server do in that case? It should handle it correctly, but iOS can't guarantee that.

OTOH, if I read your original question literally, you seem to be asking about this case:

  1. you build an app using NSURLSession
  2. you deploy a server that supports HTTP/2
  3. on iOS 9, this will talk to your server via HTTP/2
  4. on iOS 8, will it send HTTP/2 requests?

The answer here is no: the HTTP/2 support is part of iOS 9, and thus won't be available on earlier OS releases. OTOH, iOS 8 does have support for SPDY. See WWDC 2014 Session 707 What's New in Foundation Networking for details.

HTTP/2 supported by iOS 9 + NSURLSession.

NSURLConnection 已弃用。