Authorization header is set in NSURLSessionConfiguration
, however it is not attached to NSURLSessionDataTask
. Is this a bug in Foundation framework
?
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
[configuration setHTTPAdditionalHeaders:@{@"Authorization":@"123"}];
// Initialize session with NSURLSessionConfiguration
NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
NSURLSessionDataTask *sessionTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
}];
[sessionTask resume];