关于afnetworking加入header
1 AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; 2 manager.requestSerializer = [AFHTTPRequestSerializer serializer]; 3 manager.responseSerializer = [AFJSONResponseSerializer serializer]; 4 //加入header的key和value 5 [manager.requestSerializer setValue:value forHTTPHeaderField:key];
6 NSLog(@"header-------%@",manager.requestSerializer.HTTPRequestHeaders); 8 manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html", @"application/json",@"text/plain", nil]; 9 [manager GET:urlStr parameters:nil progress:nil 10 success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { 11 NSLog(@"-----------%@",responseObject); 12 } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { 13 NSLog(@"error-------%@",error); 14 15 }];