nsurlsessionconfiguration

nsurlsession for multiple request in loop

北慕城南 提交于 2020-01-05 08:42:09
问题 I have been trying to download image/txt but i need to do it until that url exists & download that image/txt file,so i keep calling same method again & when i set debug point i see this . If url is right than i do not see any queue in debug navigator because it is not calling method again. i referred AFNetworking library to the same but i guess it`s working in same way as i am doing in NSURLSession,right? Case:- I check for url if exists or not, so if it`s exists than load both urls(time.txt

nsurlsession for multiple request in loop

我怕爱的太早我们不能终老 提交于 2020-01-05 08:41:57
问题 I have been trying to download image/txt but i need to do it until that url exists & download that image/txt file,so i keep calling same method again & when i set debug point i see this . If url is right than i do not see any queue in debug navigator because it is not calling method again. i referred AFNetworking library to the same but i guess it`s working in same way as i am doing in NSURLSession,right? Case:- I check for url if exists or not, so if it`s exists than load both urls(time.txt

How to programmatically add a proxy to an NSURLSession

大憨熊 提交于 2019-12-28 02:39:13
问题 Looking over the documentation of NSURLSession and NSURLSessionConfiguration , I was under the impression I should configure it with a dictionary like the following: // Create a dictionary to describe the proxy NSDictionary *proxyDict = @{ (NSString *)kCFProxyHostNameKey : @"myProxyHost.com", (NSString *)kCFProxyPortNumberKey : @"12345", (NSString *)kCFProxyTypeKey : (NSString*)kCFProxyTypeHTTP }; // Create a configuration that uses the dictionary NSURLSessionConfiguration *configuration =

NSURLSessionConfiguration HTTPAdditionalHeaders not set

一曲冷凌霜 提交于 2019-12-22 05:52:51
问题 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 = [

How to upload task in background using afnetworking

前提是你 提交于 2019-12-21 04:06:30
问题 I'm trying to upload large files using AFNetworking and have the upload continue when the application is in the background. I can upload files just fine, but when I attempt to use a background configuration -- the application crashes with the following stacktrace: Exception: EXC_BAD_ACCESS (code=1, address=0x8000001f)) _CFStreamSetDispatchQueue -[__NSCFBackgroundDataTask captureStream:] __70-[__NSCFBackgroundDataTask _onqueue_needNewBodyStream:withCompletion:]_block_invoke_2 _dispatch_call

AFHTTPSessionManager block is not called when app is on background

Deadly 提交于 2019-12-13 01:37:26
问题 My app get a silent push, then do some http request in background using AFNetworking,but it didn't enter the complete block, code is: AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc] init]; [manager GET:urlString parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) { NSLog(@"response objece:%@", responseObject); } failure:^(NSURLSessionDataTask *task, NSError *error) { NSLog(@"error:%@", error); }]; then I found maybe I could use NSURLSessionConfiguration to

Initializer does not override a designated initializer while subclassing NSURLSession Swift

别来无恙 提交于 2019-12-11 13:15:42
问题 I want to subclass NSURLSession class, but I have problem with initialisation. Basically I override the constructor and initialising the constant authUrl there then calling the parent init method. class NSURLAuthSession: NSURLSession { let authUrl:NSURL; //Error: Initializer does not override a designated initializer from its superclass override init(configuration: NSURLSessionConfiguration, delegate: NSURLSessionDelegate?, delegateQueue queue: NSOperationQueue?){ self.authUrl = NSURL

Maximum # Simultaneous Downloads with NSURLSession Regardless of Host

吃可爱长大的小学妹 提交于 2019-12-11 04:32:08
问题 I know about the HTTPMaximumConnectionsPerHost option on NSURLSessionConfiguration ... but how many connections can iOS handle irrespective of host? I assume this depends on some combination of... the # of cores.. the network interface.. and how busy the OS is in general + with downloads for other applications. Can't find any hints about this. Regardless I assume it's ridiculous to expect more than 2 or 3 at once.. Edit Assuming the ability to have as many hosts and NSURLSession instances as

Resume upload task using NSURLSessionUploadTask after app is killed?

一世执手 提交于 2019-12-11 00:15:14
问题 I am using the following code to upload image using NSURLSessionUploadTask NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration]; NSURL *URL = [NSURL URLWithString:@"http://example.com/upload"]; NSURLRequest *request = [NSURLRequest requestWithURL:URL]; NSURL *filePath = [NSURL fileURLWithPath:@"file://path/to/image.png"]; NSURLSessionUploadTask

unable to upload file using NSURLSession multi-part form data in iOS

走远了吗. 提交于 2019-12-09 14:27:37
问题 I am trying to upload a video / image file using - (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request fromFile:(NSURL *)fileURL; method using multi-part form data. But somehow i am not able to upload the file and i am getting " stream ended unexpectedly " error. Requirements Upload a video / image file to server App should support background uploads (Continue the upload process even after app goes into background) Server expects the data to be sent using multi-part form