All-Seeing Interactive Logo

ASIHTTPRequest documentation

Last updated: 31st December 2008



What is ASIHTTPRequest?

ASIHTTPRequest is an easy to use wrapper around the CFNetwork API that makes some of the more tedious aspects of communicating with web servers easier. It is written in Objective-C and works in both Mac OS X and iPhone applications.

It is suitable performing basic HTTP requests and interacting with REST-based services (GET / POST / PUT / DELETE). The included ASIFormDataRequest subclass makes it easy to submit POST data and files using multipart/form-data.

It provides:

  1. Downloading to a file is not supported in iPhone applications

ASIHTTPRequest comes with a simple Mac OS X application that demonstrates many of the features above. Just look at AppDelegate.m for good pointers on basic usage, or read the comments in ASIHTTPRequest.h for more detail. A basic iPhone sample application is also included.

ASIHTTPRequest is partly based on code from Apple's ImageClient code samples, so if it doesn't meet your needs, take a look at their CFNetwork examples for more.

ASIHTTPRequest is my first open source Objective-C code. I hope to expand the class and example application further in the coming months. If you find it helpful, please do get in touch!

ASIHTTPRequest is compatible with the Mac OS 10.5 (Leopard) API and the iPhone 2.1 API, it will not work with Mac OS 10.4. The sample project is in Xcode 3.1 format.


An overview of the classes

ASIHTTPRequest

Handles the basics of communicating with webservers, including downloading and uploading data, authentication, cookies and progress tracking.

ASIFormDataRequest

A subclass of ASIHTTPRequest that handles multipart/form-data posts. It makes POSTing data and files easy, but you do not need to add this to your project if you want to manage POST data yourself or don't need to POST data at all.

ASINetworkQueue

A subclass of NSOperationQueue that may be used to track progress accross multiple requests. You don't need this if you only need to perform one request at a time, or prefer to track the progress of each request individually.

NSHTTPCookieAdditions

A helper category of NSHTTPCookie that encodes and decodes the values of cookies. You need to include this in your project whether you are using cookies or not.