We’re not quite sure how we managed to overlook this so far, but if you’re outgrowing NSConnection and figure that you need something CFNetwork based, there is an excellent library called ASIHTTPRequest that wraps it nicely, is compatible with iPhone and desktop both, and has plenty of features, some of the more nifty being:
- The ability to submit files on local drives as part of POST data, compatible with the HTML file input mechanism
- Basic, Digest and NTLM authentication support, credentials are automatically for the duration of a session, and can be stored for later in the Keychain.
- GZIP support for response data AND request bodies
- Basic support for Amazon S3
- Full support for Rackspace Cloud Files
- Bandwidth throttling
- Supports manual and auto-detected proxies, authenticating proxies, and PAC file auto-configuration. The built-in login dialog lets your iPhone application work transparently with authenticating proxies without any additional effort.
Yes, that is indeed a comprehensive feature list. Source on github; group on Google; and Lighthouse bug base even. And BSD-licensed to boot. Why, it’s like an awesome sundae topped with awesome sauce!
[UPDATE: But ho! The very next day, we stumble across a purported good reason to NOT use it —
I’m sorry, I have to speak out against the ASIHTTP library. It’s mostly quite good, but because it doesn’t sit on the NSURL* classes it ignores any global proxy settings. This is particularly an issue in a VPN environment, but it comes up in other situations as well. Unless you’re willing to deal with wonky support issues (and bad reviews as a result), don’t use it.
Hmmm. That does sound like a worry … but we could swear that CFNetwork can use CFProxySupport to get the global proxy settings, because we’ve done that. On the desktop, mind you. Perhaps CFProxySupport is not available/functional on the iPhone? Or this fellow is just making stuff up? If you have some actual iPhone experience to know one way or the other, please share!]