#apple & OSX   #coding   #ruby   #test   #understanding: IT

webdav-exporter ruby gem: serve files from the commandline

January 1, 2007

I finally got around packing my WebDAV experiments into a gem to put it on rubyforge for easy deployments. sudo gem install webdav-exporter should do.

What it does is to install an executable ruby script by which you can start-up a webdav fileserver right from your comandline with no need for further setup.

WARNING: this is super alpha! tested on my macbook only!

webdav-exporter.rb ~/taxi

for example will export the taxi folder in your home directory. The webdav-exporter gem is build on top or Tatsuki Sugiura WEBrick WebDAV handler gem(gem install webrick-webdav), which in turn builds on top of the ruby build-in webrick server.

I tricked the webdav servlet into claiming DAV2 protocol compliance. This was to make writable mounts on my mac possible. With DAV1 and no LOCK method implementation my mac osx refused to mount the exported files as writable, and without writable mounts the whole webdav is not worth the efforts of course.

def do_OPTIONS(req, res)
res["DAV"] = "1,2"

def do_LOCK(req, res)
res.body << "<XXX-#{Time.now.to_s}/>"

you see what i mean with tricked, but this is actually quite ok for 1. it works on my macbook, 2. it gets me rid of the annoying errors when not having a do_LOCK method at all and 3. the webdav rails plugin does actually not do any better concerning the LOCK implementation.

So, no need starting a rails app or talk to your sysad for easy filesharing any more. The server does HTTPS only and for the default 443 port you need root permissions. For the SSL stuff all credits go to Gabriele Marrone with whom i did discuss the issue on the ruby forum.

WebDAV was such a nice idea but i guess it was the greed in the cooperate computer industry which rendered this technology practically useless. Hardly any two implementations are compatible. If you wonder why i tricked the implementation instead of implementing it, go check out the WebDAV RFC, it is a disaster and i could not make sense of it(was not willing to waste my time on it). We are dwarfs standing on the shoulder of giants and with this gem i could make it working for me. If it works for you tell me, it not tell me also.

happy new year and have a lot of fun

share this: