AFNetworking/AFNetworking — pull request #396 by lansing (2012-06-30 23:45:39+00:00)
Title: Extreme streaming

Hey homeboy, check out this reimplementation of the HTTP multipart stuff. Rather than piling on one hack after another to get the temporary file stuff working, I created an nsinputstream subclass that aggregates your form datas and your file urls, handles building the headers, and doesn't use any temp files.

It's basically a drop-in replacement for the previous implementation, although I cut out a bunch of the public API for composing the request. I feel like there's no point in taking pains (and believe me, it was painful) to build a multipart request correctly via this method, only to let people bone it up themselves by appending data without the proper headers, etc. If they want to do that they should subclass. So really all you can do is attach a form data object or attach a file.

There are a bunch of stubbed out methods in the nsinputstream subclass which are simply required to avoid a runtime exception (not that Apple documented this fact). I also added the MobileCoreServices framework to the ios project, which is required to get the MIME type from the filename (although it's kinda not chill that this will break existing projects that don't have this framework added, with some bogus error).