HTTP / 2 Server Click in iOS 10

I am trying to get the server to work with iOS 10. I am working on a demo version of Akamai HTTP / 2.

https://http2.akamai.com/demo

Below is my attempt at testing a push server.

@interface ViewController () <NSURLSessionTaskDelegate>

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration];
    NSURLSession *defaultSession = [NSURLSession sessionWithConfiguration: defaultConfigObject delegate: self delegateQueue: [NSOperationQueue mainQueue]];

    NSString *displayArtUrl;
    for(int i=0; i<378; i++) {
        displayArtUrl = [NSString stringWithFormat:@"https://http2.akamai.com/demo/tile-%ld.png", (long)i];
        NSURL *url = [NSURL URLWithString:displayArtUrl];
        NSURLSessionDataTask *downloadTask = [defaultSession
                                              dataTaskWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
                                              }];
        [downloadTask resume];
    }

}

- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didFinishCollectingMetrics:(NSURLSessionTaskMetrics *)metrics {
    NSArray *fetchTypes = @[ @"Unknown", @"Network Load", @"Server Push", @"Local Cache" ];

    for(NSURLSessionTaskTransactionMetrics *transactionMetrics in [metrics transactionMetrics]) {

        NSLog(@"protocol[%@] reuse[%d] fetch:%@ - %@", [transactionMetrics networkProtocolName], [transactionMetrics isReusedConnection], fetchTypes[[transactionMetrics resourceFetchType]], [[transactionMetrics request] URL]);

        if([transactionMetrics resourceFetchType] == NSURLSessionTaskMetricsResourceFetchTypeServerPush) {
            NSLog(@"Asset was server pushed");
        }
    }
}

@end

Unfortunately, the logs show that the sample type is always NSURLSessionTaskMetricsResourceFetchTypeNetworkLoad, when I expect it to be NSURLSessionTaskMetricsResourceFetchTypeServerPush sometimes. The server obviously supports it, as seen in the web demo.

...
2016-11-22 19:27:37.596205 HttpServerPush[2356:735927] protocol[h2] reuse[1] fetch:Network Load - https://http2.akamai.com/demo/tile-4.png
2016-11-22 19:27:37.596960 HttpServerPush[2356:735927] protocol[h2] reuse[1] fetch:Network Load - https://http2.akamai.com/demo/tile-5.png
2016-11-22 19:27:37.597877 HttpServerPush[2356:735927] protocol[h2] reuse[1] fetch:Network Load - https://http2.akamai.com/demo/tile-6.png
2016-11-22 19:27:37.603988 HttpServerPush[2356:735927] protocol[h2] reuse[1] fetch:Network Load - https://http2.akamai.com/demo/tile-1.png
2016-11-22 19:27:37.976911 HttpServerPush[2356:735927] protocol[h2] reuse[1] fetch:Network Load - https://http2.akamai.com/demo/tile-7.png
....

Has anyone had success with an HTTP / 2 server on iOS 10? Is something missing in how assets are requested?

FYI, Charles Proxy seems to be interfering in this scenario. Enabling this causes iOS 10 to completely stop using HTTP / 2.

...
2016-11-22 19:55:15.763 HttpServerPush[59822:1612935] protocol[http/1.1] reuse[1] fetch:Network Load - https://http2.akamai.com/demo/tile-8.png
2016-11-22 19:55:15.766 HttpServerPush[59822:1612935] protocol[http/1.1] reuse[1] fetch:Network Load - https://http2.akamai.com/demo/tile-11.png
2016-11-22 19:55:15.769 HttpServerPush[59822:1612935] protocol[http/1.1] reuse[1] fetch:Network Load - https://http2.akamai.com/demo/tile-9.png
2016-11-22 19:55:15.771 HttpServerPush[59822:1612935] protocol[http/1.1] reuse[1] fetch:Network Load - https://http2.akamai.com/demo/tile-12.png
...
+2
source share
2 answers

, - Akamai . , PUSH_PROMISE . nghttp ( brew Mac OS X: brew install nghttp2) , :

$ nghttp -nv 'https://http2.akamai.com/demo' | grep 'PUSH_PROMISE'
$

, https://h2o.examp1e.net/, HTTP- H2O, :

$ nghttp -nv 'https://h2o.examp1e.net' | grep 'PUSH_PROMISE'
[  0.587] recv PUSH_PROMISE frame <length=59, flags=0x04, stream_id=13>
[  0.587] recv PUSH_PROMISE frame <length=33, flags=0x04, stream_id=13>
[  0.588] recv PUSH_PROMISE frame <length=35, flags=0x04, stream_id=13>
[  0.588] recv PUSH_PROMISE frame <length=24, flags=0x04, stream_id=13>
[  0.588] recv PUSH_PROMISE frame <length=28, flags=0x04, stream_id=13>
$
+1

, HTTP/2 Push iOS, :

https://www.shimmercat.com

. HTTP/2 Push iOS 10!

0

Source: https://habr.com/ru/post/1686888/


All Articles