nsurlsession

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

Sending post data nsurlsession

不想你离开。 提交于 2019-12-11 03:46:01
问题 Hi i'm trying to replicate the following curl command in swift using NSURLSession in a playground. curl -k -i -H "Accept: application/json" -H "X-Application: " -X POST -d 'username=&password=' https://address.com/api/login Here's what I've got so far. Where i'm struggling is that i'm unsure how to send the post data e.g.: 'username=&password='. Any help would be appreciated. Thanks in advance. import Foundation import XCPlayground // Let asynchronous code run

How to convert AFNetworking service invoke to use AFHTTPSessionManager

☆樱花仙子☆ 提交于 2019-12-11 03:28:26
问题 This is my current call to (asmx) SOAP web service: NSString *soapMessage = [NSString stringWithFormat: @"<?xml version=\"1.0\" encoding=\"utf-8\"?>" "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" "<soap:Body>" "<Save xmlns=\"http://www.myapp.com/\">" "<par1>%i</par1>" "<par2>%@</par2>" "<par3>%@</par3>" "</Save>" "</soap:Body>" "</soap:Envelope>", par1, par2,

How to determine when NSURLSessionTask's request begins?

纵饮孤独 提交于 2019-12-11 03:24:17
问题 I use NSURLSessionTask s and I'm trying to monitor how long some of my HTTP Requests take, what delegate method (or something else) can I monitor for when the NSURLSessionTask actually makes the initial request? If this were a NSURLConnection inside an NSOperation I'd just start a timer when I start the request but I don't have control over when tasks start. 回答1: Please check NSURLSessionTaskDelegate . It has following delegate callbacks: URLSession:task:didCompleteWithError: URLSession:task

NSURLSession bandwidth limiting

断了今生、忘了曾经 提交于 2019-12-11 02:15:50
问题 Is there a way to limit the bandwidth in NSURLSession ? I'm making file-sync-client for macOS like Dropbox/GoogleDrive/pCloud and they all have bandwidth limiting options, but I'm not sure how to configure NSURLSession to respect bandwidth limiting. 回答1: Unless Apple has added something very recently, NSURLSession provides no facilities for bandwidth limiting. The only ways I'm aware of to do that are: Use lower-level APIs that allow you to provide your own sockets and then throttle the data

URLSession best practice - multiple requests

最后都变了- 提交于 2019-12-11 02:14:11
问题 I need a little guidance on best practice with URLSession/NSURLSession . My requirement stipulates that I have to do adhoc/periodic HTTP GET requests. i.e. Every few mins, then maybe every 30 seconds, changing at will. Anyway I've achieved this as follows, I have a method that contains code like this: let urlRequest = URLRequest(url: url) // set up the session let config = URLSessionConfiguration.default let session = URLSession(configuration: config) // make the request let task = session

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

What is the proper use case for NSURLSessions background sessions?

不羁的心 提交于 2019-12-10 22:28:11
问题 In the comments of this answer I was having a discussion about backgroundTasks which eventually led to: Use backgroundTasks for anything that isn't related to download/upload. For upload/download use NSURLSessions's backgroundSessions. Then I made another comment asking why not use background Sessions for all types of requests and was told: For regular REST calls, background sessions are much less convenient, and generally not what you'd want. They're not a general purpose tool for every

NSURLSessionUploadTask not passing file to php script

别说谁变了你拦得住时间么 提交于 2019-12-10 17:26:30
问题 EDIT: Ok, I just set the content-type header to multipart/form-data with no difference. My original question is below: This is my first question on stack overflow, I hope I'm doing it right. I am only learning Objective-C, having recently completed the online version of the Stanford course. I know virtually nothing about php and html. The php script and the html I am using are mostly copied off a tutorial. Obj-C makes more sense to me. The problem: I have a php script. It uploads an image

NSURLSessionTask. Suspend does not work

自古美人都是妖i 提交于 2019-12-10 13:29:17
问题 This is what Apple's documentation says regarding suspend method of NSURLSessionTask class A task, while suspended, produces no network traffic and is not subject to timeouts. Ok. So I'm running the following simple code: let url = NSURL(string: "http://httpbin.org/delay/10")! let urlRequest = NSURLRequest(URL: url) self.task = NSURLSession.sharedSession().dataTaskWithURL(urlRequest.URL!, completionHandler: { data, response, error in print("completion ERROR \(error)") }) self.task.resume()