Я пытаюсь заставить сервер работать с iOS 10. Я работаю над демо-версией Akamai HTTP/2.HTTP/2 Server Push in iOS 10
Ниже моя попытка тестирования сервера толчке.
@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
К сожалению, журналы показывают, что тип выборки всегда NSURLSessionTaskMetricsResourceFetchTypeNetworkLoad, когда я хотел бы ожидать, что это будет NSURLSessionTaskMetricsResourceFetchTypeServerPush иногда. Сервер, очевидно, поддерживает его, как видно из веб-демонстрации.
...
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
....
У кого-то был успех с HTTP/2-сервером на iOS 10? Что-то не хватает в том, как запрашиваются активы?
FYI, Charles Proxy, похоже, мешает в этом сценарии. Включение этого приводит к тому, что iOS 10 полностью прекращает использование 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
...
Благодарим вас за указание на nghttp. Это очень полезно. Похоже, моя ошибка предполагала, что демо-версия Akamai HTTP/2 была исполнена, потому что она использовала HTTP/2 Server Push. Похоже, что это из-за мультиплексирования. – gototen