How to check in IOS 9 if HTTP/2 is used?

Hi,


I have upgraded my server with Jetty 9.3 to enable HTTP/2.


My IOS is communicating successfuly with the server but how can I check on in my IOS App if HTTP/2 is used instead of HTTP 1.1?


My App is using Donwload tasks from NSURLSession, is there a way to retreive from the response the protocol that has been used with the server?

Thanks,


Sébastien.

Accepted Reply

In my servlet I was able to check it by using HttpServletRequest.getProtocol(), now I'm sure my IOS 9 App is using HTTP/2.


Maybe it would be interesting to get also this info from NSURLSession because we don't have always access to the server ?

Replies

I don't think there's a way to ask NSURLSession what protocol was used. You might be able to get this info from your server logs. Failing that, you could look at the traffic on the wire.

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

In my servlet I was able to check it by using HttpServletRequest.getProtocol(), now I'm sure my IOS 9 App is using HTTP/2.


Maybe it would be interesting to get also this info from NSURLSession because we don't have always access to the server ?

Maybe it would be interesting to get also this info from NSURLSession because we don't have always access to the server ?

I think it would be. Originally I thought that might be possible because NSHTTPURLResponse knows the HTTP version of the response (note that it's one of the parameters to

-initWithURL:statusCode:HTTPVersion:headerFields:
). But annoyingly there's no
HTTPVersion
property so, while the object has the value, there's no way to get it out. I had a chat with CFNetwork Engineering about this and they confirmed my analysis.

So, if you think this would be useful to you, please file an enhancement request for this API. I'd appreciate you posting your bug number here, just for the record.

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

I have created the enhancement: #22037943.

You can enable CFNetwork Diagnostic Logging and check raw response headers/data


https://developer.apple.com/library/content/qa/qa1887/_index.html

Indeed.

And in iOS 10 and friends you can get the metrics for each task (NSURLSessionTaskMetrics) and look at the

networkProtocolName
of the various NSURLSessionTaskTransactionMetrics objects.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

i think this should be marked as correct answer

Agreed, NSURLSessionTaskMetrics is the way to go! Thanks.


(Hi Alex!)