2

NSURLSession Request HTTP/2.0

working in iOS9.

enter image description here

but invalid in iOS10

enter image description here

my code :

 

    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];

Maxim Pavlov
  • 2,962
  • 1
  • 23
  • 33
李江淮
  • 43
  • 7

1 Answers1

9

It looks like Charles Proxy 4 will cause iOS 10 to not use HTTP/2. It seems to work fine with iOS 9.

You can demonstrate this by loading the Akamai HTTP/2 demo in Mobile Safari in iOS 10:

https://http2.akamai.com/demo

If you enable Charles Proxy while visiting the site it will report to you that your browser does not support HTTP/2.

gototen
  • 138
  • 1
  • 7
  • This is right answer. Charles Proxy 4 makes iOS 10 not to use HTTP/2. Use iOS 9 if you need to sniff HTTP/2 request using Charles Proxy 4. – ccoroom Nov 25 '16 at 08:48
  • Also, for those that are wondering, the iOS 9 simulators do work for this. – Sandy Chapman May 17 '17 at 00:58
  • I have the same behaviour with Charles and NSURLSession using HTTP 2 but this is kind if strange. Why would Charles make the HTTP 2 fail while it succeeds at proxying other HTTP 2 requests (e.g. curl) – Jan Oct 03 '17 at 18:38