toxicsoftware.com

RANDOMIZE USR 0

toxicsoftware.com header image 2

Is that an HTTP server in your Cocoa application or are you just pleased to see me?

February 17th, 2006 · Comments · Default

This is a little 30 second/1.4MB screencast showing a little idea I had to embed a simple HTTP server inside a Cocoa application. The screencast just shows an application hosting a basic HTML form that allows someone browsing to the application’s address to modify the applications defaults. Changes to the HTML form are reflected live in the Cocoa Application’s GUI.

This is pretty neat in its own right but isn’t too useful to the average Cocoa application. Still I can see a few types of applications making good use of this, for instance combined with Bonjour broadcasting this could become a great interface for controlling background daemons from any machine. Alternatively web editors like Sandvox could host their own mini web servers to provide a quick way of realistically previewing websites in Safari. Applications that edit hyper-linked data (mentioning no names) could benefit from hosting the data in a web server too.

Some interesting uses for the code would be to provide a “poor man’s RemoteDesktop” style application and use the Universal Access api to populate an HTML based alternative GUI for an application. I don’t think I have the time to code this hack but it would be interesting to see how useful it could be made to be. And for extra points write it as an InputManager and provide a HTML interface to every application (the author in no way encourages the use of dirty evil hacks written as Input Managers, Input Managers are of course the loadable bundle of the beast and should of course be avoided at all times because of course Apple (Apple be praised) knows best - even if you can do some really freaking cool things with hacks).

Over the next week or so I’ll try to release the code to the HTTP server. The code is actually rather old (written for 10.0 IIRC) having originally been written as a HTTP client library for a XML SOAP implementation I wrote that never saw the light of day (but may bundle with this code when I release it). The code was modular enough that it was pretty easy to turn the HTTP client code into HTTP server code. It consists of a bunch of ObjC socket wrappers (like SmallSocket) and HTTP classes themselves. I have since created a framework (ToxicWarped) that works in a similar way to Python’s Twisted library and will try to modify my code to use that and also CFSocket instead of my socket code.

And a quick warning, obviously this code could constitute a major security risk if the embedded in an application that exposes the wrong kind of information via HTTP. Also, the HTTP server is obviously no where near the quality/robustness of Apache or Lighttpd, if you actually need to serve real content from your Cocoa application then I am pretty sure my code isn’t enough.

Tags:

Viewing 6 Comments

 
close Reblog this comment
blog comments powered by Disqus