Introducing CKHTTPConnection

Again. Or CKHTTPConnection II perhaps. Wait Mike, back up.

As the handful of you that read this blog know, I've been spending a fair bit of time lately working on ConnectionKit. Recently we pushed out 1.2 and 1.2.1 releases of the framework; improving the API, particularly in the area of authentication. At the same time I've been pondering over the question of ConnectionKit's future and toying around with a version 2.0 of the framework.

Now ConnectionKit 2.0 is nowhere near ready for primetime,  but it does contain a component that may be useful to others so I thought I'd blog it here for feedback. I've written a brand new CKHTTPConnection class (CK 1.x contains an identically name class, but with a totally different purpose).

What is it and why might I want it?

CKHTTPConnection provides a sort of "NSURLConnection lite" API. All the core methods are there, but it deals only with HTTP connections, and strips out cookie handling & caching. Also it runs asynchronously on a single thread unlike NSURLConnection's internal use of a worker thread that manages all connections.

So, it's a crappy version of a mature class already in the Foundation framework. Not really selling it am I.

Where this really comes in handy is for applications which use HTTP, but for more than data fetches. Perhaps you have a custom communications protocol which is built atop HTTP for simplicity. If so CKHTTPConnection's simplicity and level of control can be a big win.

Finally the class has one more trick up its sleeve. For anyone performing POST or PUT operations, NSURLConnection is pretty weak as it provides no API for tracking upload progress. CKHTTPConnection has a handy -lengthOfDataSent method. This could make it a big win for adding progress tracking to an existing codebase; just drop in CKHTTPConnection (it has a virtually identical API) and implement the new delegate methods.

Why are you telling me this?

As I know there are potential uses outside of the ConnectionKit framework for this class, and 2.0 will not be ready for some time, I thought it would be good to get the word out. I'm very interested in feedback on any ways CKHTTPConnection could be improved to match others' usage. For example, this has the potential to be fantastically helpful for tracking upload progress, and you might require cookie support in tandem with that (presumably for authentication purposes). I'd be happy to add it if so.

Where can I get it?

While 2.0 is being developed on its own branch:


Access to the main repository is at

It's all available under a BSD style license.

© Mike Abdullah 2007-2015