iOS10 NSURLSession HTTP/2无效

李江淮*_*李江淮 2 http2 ios10 charles-proxy

NSURLSession请求HTTP/2.0

在iOS9中工作.

在此输入图像描述

但在iOS10中无效

在此输入图像描述

我的代码:

 

    NSURLSession *session = [NSURLSession sharedSession];
    request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://ga.seeyouyima.com/page"]];
    [request setHTTPMethod:@"POST"];
    [[session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
        if (completedBlock) {
            completedBlock(data, response, error);
        }
    }] resume];

Run Code Online (Sandbox Code Playgroud)

小智 9

看起来Charles Proxy 4会导致iOS 10不使用HTTP/2.它似乎适用于iOS 9.

您可以通过在iOS 10中的Mobile Safari中加载Akamai HTTP/2演示来证明这一点:

https://http2.akamai.com/demo

如果您在访问站点时启用Charles Proxy,它将向您报告您的浏览器不支持HTTP/2.