robbiehanson/CocoaHTTPServer — Issue #5: Add run-time information to CocoaHTTPServer using custom Response class
Author: besi
Created: 2012-01-26 13:00:36+00:00
State: open

I have the following code to start my own [Cocoa HTTP Server](https://github.com/robbiehanson/CocoaHTTPServer). In order to manually handle the responses I have created my custom `HTTPConnection` class named `PictureHTTPConnection`

self.httpServer = [[HTTPServer alloc]init];
self.httpServer.type = @"_http._tcp.";
self.httpServer.name = @"MyBonjour Name";
self.httpServer.connectionClass = [PictureHTTPConnection class];

The problem here is that the `PictureHTTPConnection` class needs some information in order to handle the HTTP connections. However, I only provide the class and therefore I don't have a reference to the instance. I could do something with global data but this is not very good programming practise.

The best way I can think of is setting the `PictureHTTPConnection`'s delegate to the `UIApplicationDelegate` so that it can answer any callbacks. :-(