With work having recently stopped on ASIHTTPRequest, it seems like attention is shifting to AFNetworking.
However, I've not yet found a good comparison of the features of the two libraries, so I don't know what I might lose if/when I switch over.
Major differences I've spotted so far are:
- AFNetworking has a much smaller code size (which is good)
- AFNetworking is being rapidly improved (so it may not yet be mature, may not have a stable API yet?)
- Both seem to have caching, though I've seen hints that because AFNetworking uses NSURLConnection it won't cache objects over 50K
- ASIHTTPRequest has very good support for manual & automatic (PAC) http proxies; I can't find any information on what level of support AFNetworking has for proxies
- AFNetworking requires iOS 4+, whereas ASIHTTPRequest works right back to iOS 2 (not really an issue for me, but it is an issue for some people)
- AFNetworking doesn't (yet) have a built in persistent cache, but there's a persistent cache which has a pending pull request: https://github.com/gowalla/AFNetworking/pull/25
Has anyone seen any good comparisons of the two libraries or any documented experiences of switching from one to the other?
Just finishing up a project where I'm using AFNetworking instead of ASI. Have used ASI on previous projects; it's been a great help in the past.
Here's what AFNetworking is missing (as of today) that you should know about:
ASI is going away. Use AF now. It's small, it works, and it's going to continue to be supported. It's also organized more logically, especially for API clients. It has a number of great classes for oft-used special cases like asynchronous loading of images in table views.
I've been using ASI* for a while now and I absolutely love the fileupload approach of ASI, and though I am excited to jump to AFNetworking, fileupload support in AfNetworking is not as easy to use compared to ASI*.
Until nowI couldn't figure out how to set a timeout with AFNetworking when doing a synchronous POST request. UPDATE: I finally figured out: https://stackoverflow.com/a/8774125/601466Now switching to AFNetworking : ]
==================
Apple overrides the timeout for a POST, setting it to 240 seconds (in case it was set shorter then the 240 seconds), and you can't change it. With ASIHTTP you just set a timeout and it works.
A code example with a synchronous POST request:
I tried to set a timeout here, but nothing worked. This issue keeps me from migrating to AFNetworking.
See also here: How to set a timeout with AFNetworking
AFNetworking doesn't support clientCertificateIdentity and clientCertificates for TLS client authentication.
We can do that with the
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
method in a subclass of AFURLConnectionOperation but it's not as easy.In ASIHTTP I loved that I could attach a userinfo dictionary to individual requests. As far as I see there is no direct support for this in
AFHTTPRequestOperation
. Has anyone come up with an elegant workaround yet? Apart from the trivial subclassing of course.AFNetworking works with "blocks" which is more natural for me than working with delegates like ASIHTTPRequest does.
Working with blocks it's like working with Anonymous Function in javascript.