t_ms t_ms - 2 years ago 231
Objective-C Question

Http/2 server_push with NSURLSession

I have implemented a program to communicate http2 using NSURLSession of iOS9, And it can communicate with my server in http2.
However, I'm having a problem with receive server_push.
I found ENABLE_PUSH value is 0 in their settings and there's no delegate in receive server push in NSURLSession...

・I think NSURLSession doesn't support server_push. Is this right?

・If it support server_push,how to use?

It WORKS for post data and get response.
I don't know the code should be added here
in order to get the server_push.
I suspect that NSURLSession itself cannot receive the server_push(;_;)
- (void) postData
NSString *urlstr = self.urlArea.text;
NSURL * url = [NSURL URLWithString:urlstr];
NSDictionary *params = @{@"data":@""};
//json to query
NSData *query = [self buildQueryWithDictionary: params];

//make request
NSMutableURLRequest *request = [NSMutableURLRequest
cachePolicy: NSURLRequestReloadIgnoringCacheData
timeoutInterval: 10.0];
[request setHTTPMethod: @"POST"];
[request setHTTPBody: query];

//prepare session
NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration] delegate:self delegateQueue:[NSOperationQueue mainQueue]];

[[session dataTaskWithRequest: request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error)
if (response && ! error) {
NSLog(@"Data: %@", [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding]);
}else {
NSLog(@"ERR: %@", error);
}] resume];

Answer Source


I received following reply from support.

iOS does not currently support this.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download