thumper: My Ugly Little Ocaml Web Server

July 17th, 2007

Spent the afternoon cobbling together a simple Ocaml web server and – to spite my normally reclusive attitude when it comes to personal projects – I thought I’d share the results. The interesting stuff is in thumper.ml. Refer to line 215 if you’re interested in implementing your own handlers for primitive resources.

I’m sure there’s room for improvement, so I’ve uploaded a tarball of the bzr repository. You can get it here: Thumper v0.1. Any suggestions/patches?

Note: This is not the next part of my series of Ocaml tutorials. That’s likely to come after I’ve finished moving. :)

Categories: Functional Programming, Ocaml, Software Development |

3 Comments

  1. Bill Hacker

    Thomas,

    Quite an amazing example!

    A mere 249 lines of Ocaml (188 stripped of whitespace and comments), and it http-perf and webbench astonishingly good numbers!

    Nothing raises interest in a language better than *readable* code samples that ‘JFW’.

    Ruby? Python? Simple languages with insanely complex apps (Zope/Plone, Rails …

    ‘Bend over, grab your ankles, … and kiss your anatomy goodbye…!!!’

    Bill

  2. tom

    Hi Bill,

    It’s important to note that this is a really, really incomplete implementation of a web server. There’s little to no URI parsing (URIs are mapped directly to actions – even query strings. Bad URIs will likely be accepted). Writing a “proper” web server needs a lot more work than what I put into this. The reason it does so well in the numbers is because it doesn’t really do all that much. :)

    I’m sorry if I didn’t make that a little more clear!

    Cheers,
    T

  3. logylaps

    link broken
    http://www.vector-seven.com/wp-content/uploads/2007/07/thumper-trunktar.gz
    supposed to be
    http://www.deskchecked.com/wp-content/uploads/2007/07/thumper-trunktar.gz

Leave a comment