WEBrick+WebDAV Handler Safely Extracted From the Wild #
Adrian Madrid originally found this Ruby app called Sarada and posted it to del.icio.us. Sure enough, Tatsuki Sugiura is hiding all these great wares in his darcs repository, including a WebDAV handler for WEBrick! Uhm, let’s get this good candidate for the core distribution dusted off.
If you want to try it out, I’ve got a gem up: gem install webrick-webdav.
Here’s a sample WebDAV server, written by Sugiura:
#!/usr/bin/ruby
require 'rubygems'
require 'webrick'
require 'webrick/httpservlet/webdavhandler'
log = WEBrick::Log.new
log.level = WEBrick::Log::DEBUG if $DEBUG
serv = WEBrick::HTTPServer.new({:Port => 10080, :Logger => log})
serv.mount("/", WEBrick::HTTPServlet::WebDAVHandler, Dir.pwd)
trap(:INT){ serv.shutdown }
serv.start
I tested with cadaver localhost:10080 and listing, moving, removing, editing, putting, getting files is all there. There’s a buffer size message at the top of the source code mentioning trouble with large files, but I was able to transfer eight megs with no trouble at all. I think the comment refers to a bugfix the author made. Holy cats!
Keep in mind: it requires iconv due to the compatibility the handler tries to ensure among Konqueror, gnome-vfs, Windows, etc.

