I am not responsible for any damage.
Batteries not included.
NSURLDownload and NSURLConnection. NSURLConnection offers you much more control than NSURLDownload but at an expense; it throttles the CPU when multiple connections are made (And yes I have tested it, evening removing the delegate/custom behaviour to sample the bare bones of NSURLConnection vs NSURLDownload). I haven't found a good reason why this problem is there, in fact I thought this exact problem was supposed to be fixed with 10.6. Comparing Wget to NSURLConnection was not linear!! NSURLConnection CPU usage sometimes tripled on multiple downloads ( >1) where Wget stayed steady. In fact NSURLConnection's CPU usage was very sporadic. NSURLDownload kept itself pretty steady also, albeit slightly higher than Wget but thats to be expected. So I considered using CURLHandle and CocoaAsyncSocket but I really didn't want to have to write a lot of plumbing. So is there something I can do with NSURLDownload...NSURLDownload has its own limitations. Initially it looks promising, offering a clean interface for downloading/resuming url content. But this only works so far. Firstly you cannot set a particular point in a file to start writing to (if for example you implemented a custom resume technique). The output from class-dump did not show any way to get a handle to the file or a seek function of some sort :(NSURLDownload's resume funcitonality depends on the presence of an ETag, used to ensure a resource's validity. You may have noticed that safari does not resume a download unless this is there. A lot of servers do not support this yet, instead offered a "Last-Modified" header value. So without this ETag, NSURLDownload does not offer any way to resume a download in its public interface, whereas in NSURLConnection you can do a partial-GET request (You can also do a partial-GET with NSURLDownload but it writes to a new file, again I had an implementation concatenating files but it was messy and meant quitting the application was slow). [NSURLDownload _initWithResumeInformation:(id) delegate:(id) path:(id)] [NSURLDownload _resumeInformation]
This showed the following 4 NSDictionary key/value pairings:
NSURLDownloadBytesReceived = 4869281; NSURLDownloadEntityTag = "\"e8e019-4d4bdb26-4a5ddsaffd28c1\"";
NSURLDownloadServerModificationDate = "Wed, 15 Jul 2009 00:54:25 GMT";
NSURLDownloadURL = "http://appldnld.apple.com.edgesuite.net/content.info.apple.com/iTunes8/061-6715.20090715.cfR54/iTunes8.2.1.dmg"
Using this, even without NSURLDownloadEntityTag works with servers that do not present an ETag. This leads me to believe that, when the ETag is not present, the download sets its resumeData to nil upon cancelling the download.
So now I can resume an NSURLDownload the way I want!!
Anyway I hope this helps someone else in a similar position!
Vector out!