title: NSURLConnection on iOS 9 does not use HTTP/2 protocol
body: <p>I've configured HTTP/2 on a Jetty 9.3 server, it has a valid certificate and SSLLabs.com given it a grade A security configuration.</p>
  
  <p>Browsing using Chrome to <a href="https://example.com" rel="noreferrer">https://example.com</a> loads the correct response, it's also reporting that "h2" (HTTP/2") protocol was used.</p>
  
  <p>But when trying to access the same URL from iOS 9 using <code>NSURLConnection</code>, I can see in the request log that it used HTTP 1.1 instead. If I disable HTTP 1.1 on my server, the request will fail on iOS 9 (but still succeed on Chrome).</p>
  
  <p>NSURLConnection code -</p>
  
  <pre><code>let url = NSURL(string: "https://example.com")
  request = NSURLRequest(URL: url, cachePolicy: NSURLRequestCachePolicy.ReloadIgnoringLocalCacheData, timeoutInterval: 10)
  
  connection = NSURLConnection(request: request, delegate: self, startImmediately: true)
  </code></pre>
  
  <p>Server's ALPN debug output -</p>
  
  <pre><code>[S] ALPN protocols [spdy/3.1, spdy/3, http/1.1] received from client for 1e5e2487[SSLEngine[hostname=3.4.5.6 port=52090] SSL_NULL_WITH_NULL_NULL]
  [S] ALPN protocol 'http/1.1' selected for 1e5e2487[SSLEngine[hostname=3.4.5.6 port=52090] SSL_NULL_WITH_NULL_NULL]
  </code></pre>
  
  <p>In WWDC 2015 it was stated that NSURLRequest in iOS 9 supports HTTP/2, but the client app claims to support <code>spdy/3.1, spdy/3, http/1.1</code>, no <code>http/2</code>. There are no <code>NSAppTransportSecurity</code> exceptions set.</p>
  
  <p>I tried connecting to the server using Safari on the same iPhone Simulator running the app, this time it worked and used HTTP/2, here's ALPN debug output -</p>
  
  <pre><code>[S] ALPN protocols [h2, h2-16, h2-15, h2-14, spdy/3.1, spdy/3, http/1.1] received from client for 7b50217d[SSLEngine[hostname=3.4.5.6 port=52247] SSL_NULL_WITH_NULL_NULL]
  [S] ALPN protocol 'h2' selected for 7b50217d[SSLEngine[hostname=3.4.5.6 port=52247] SSL_NULL_WITH_NULL_NULL]
  </code></pre>
  
  <p>Any ideas why it doesn't use HTTP/2 from within the app?</p>