# Webrick-webdav(gem) served files are mounted only read-only

**URL:** <https://www.ruby-forum.com/t/webrick-webdav-gem-served-files-are-mounted-only-read-only/74281>\
**Category:** Ruby\
**Created:** [November 3, 2006, 10:11am UTC](https://www.ruby-forum.com/t/webrick-webdav-gem-served-files-are-mounted-only-read-only/74281 "2006-11-03T10:11:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![crux](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a6a055/32.png) [@crux](https://www.ruby-forum.com/u/crux)\
**Post date:** [November 3, 2006, 10:11am UTC](https://www.ruby-forum.com/t/webrick-webdav-gem-served-files-are-mounted-only-read-only/74281/1 "2006-11-03T10:11:43Z")

</div>

while i easily get a webdav server up an running with

gem install webrick-webdav

and

require ‘webrick’  
require ‘webrick/httpservlet/webdavhandler’

server = WEBrick::HTTPServer.new(context.values)  
server.mount("/webdav", WEBrick::HTTPServlet::WebDAVHandler, Dir.pwd)  
…

and can mount and read the files, i still can’t actually modify any of  
the exported/mounted webdav files.

before i start diving into real problem tracking i would like to ask if  
someone of you had the same problems? i export/mount on mac os x. might  
this be a mac or a webrick-webdav problem? any tips welcomed,

have fun  
dirk

---

<div class="post-metadata">

**Author:** ![crux](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a6a055/32.png) [@crux](https://www.ruby-forum.com/u/crux)\
**Post date:** [November 7, 2006, 10:57am UTC](https://www.ruby-forum.com/t/webrick-webdav-gem-served-files-are-mounted-only-read-only/74281/2 "2006-11-07T10:57:42Z")

</div>

Il giorno 03/nov/06, alle ore 10:11, Dirk Lüsebrink ha scritto:

> server.mount(“/webdav”, WEBrick::HTTPServlet::WebDAVHandler,  
> this be a mac or a webrick-webdav problem? any tips welcomed,
> 
> have fun  
> dirk

Exactly, that’s a Mac OS X issue: webrick-webdav supports protocol  
version 1.0, while Mac OS X wants the server to support v2.0 in order  
to let you write on that share.  
I had the same problem as yours, but I couldn’t find enough  
documentation anywhere (about webrick-webdav or about the version  
required by OS X) so I started reading webrick-webdav sources and  
comparing the traffic dump with an apache webdav module and I found  
out this version issue.  
Actually I think that the only difference between 1.0 and 2.0 servers  
is that the latter ones support LOCK methods, which allow to lock  
files (exclusive or shared locks). I didn’t need this, so I just  
inherited from WebDAVHandler:

module WEBrick  
module HTTPServlet  
class WebDAVHandlerVersion2 \< WebDAVHandler  
def do\_OPTIONS(req, res)  
super  
res[“DAV”] = “1,2”  
end  
end  
end  
end

So I started using WebDAVHandlerVersion2 instead of WebDAVHandler. In  
fact, on the source code of WebDAVHandler there is a commented out  
‘res[“DAV”] = “1,2”’ line…  
It worked, I’m quite sure I could write to that share, but right now  
it seems like it doesn’t work very well with OS X: I get strange  
errors when writing into a file or creating a new one.  
Some time ago I wrote a page about my experiments with WebDAV, since  
I couldn’t find enough documentation: [http://gmarrone.objectblues.net/](http://gmarrone.objectblues.net/)  
cgi-bin/wiki/WebDAV\_-\_Linux\_server%2c\_Mac\_OS\_X\_client .  
I summed up almost everything in this mail, but maybe you can find  
something useful over there 🙂  
It isn’t up to date, though: I don’t describe the errors I get now  
with that solution.

Please let me know if your Mac OS X is able to write without any  
error on that modified version of webrick-webdav 🙂

---

<div class="post-metadata">

**Author:** ![crux](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a6a055/32.png) [@crux](https://www.ruby-forum.com/u/crux)\
**Post date:** [November 7, 2006, 11:07pm UTC](https://www.ruby-forum.com/t/webrick-webdav-gem-served-files-are-mounted-only-read-only/74281/3 "2006-11-07T23:07:30Z")

</div>

Gabriele M. wrote:

> Il giorno 03/nov/06, alle ore 10:11, Dirk Luesebrink ha scritto:
> 
> > server.mount(“/webdav”, WEBrick::HTTPServlet::WebDAVHandler,  
> > this be a mac or a webrick-webdav problem? any tips welcomed,  
> > …  
> > I had the same problem as yours, but I couldn’t find enough  
> > documentation anywhere (about webrick-webdav or about the version  
> > required by OS X) so I started reading webrick-webdav sources and  
> > comparing the traffic dump with an apache webdav module and I found  
> > out this version issue.

yes, i’ve also found the res[“DAV”] = “1,2” but uncommenting it did not  
work for me at first. but than i found the HTTPS stuff on your  
page([http://gmarrone.objectblues.net/cgi-bin/wiki/WebDAV\_-\_Linux\_server%2C\_Mac\_OS\_X\_client](http://gmarrone.objectblues.net/cgi-bin/wiki/WebDAV_-_Linux_server%2c_Mac_OS_X_client))  
and i could get it to work. The strange errors you got, i had also,  
“(Error code, -50)”. I guess this is because of the missing UN/LOCK  
implementation and so i tried putting an empty LOCK method in there:

class WebDAVHandlerVersion2  
def do\_LOCK req, res  
puts “LOCK request: #{req}”  
end  
end

and this got me rid of the the ‘strange’ errors.

But now, what does it mean? What is UN/LOCK actually supposed to do?  
(UNLOCK does not seem to be called at all?) Yeah, i could start looking  
it up in the RFC, but i’m sick an tired of the Webdav promise. All could  
have been so nice, when apple/microsoft/apache/etc would just have had  
implemented what is written in the RFCs an i would not need to bother,  
sigh. So, now i have a kind of working(kind of) webdav-webrick/version  
2/read&write version server. lets see what happens next when putting it  
into production use, hehe

thanx  
dirk

---

<div class="post-metadata">

**Author:** ![crux](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a6a055/32.png) [@crux](https://www.ruby-forum.com/u/crux)\
**Post date:** [November 7, 2006, 11:42pm UTC](https://www.ruby-forum.com/t/webrick-webdav-gem-served-files-are-mounted-only-read-only/74281/4 "2006-11-07T23:42:43Z")

</div>

Il giorno 07/nov/06, alle ore 23:07, Dirk Lüsebrink ha scritto:

> def do\_LOCK req, res  
> puts “LOCK request: #{req}”  
> end  
> end
> 
> and this got me rid of the the ‘strange’ errors.

Great work! 🙂  
I didn’t think about it.

> into production use, hehe  
> I’ve just given a small peek at the RFC, looks like LOCK must return  
> a unique “lock token”, which should be a URI, associated to that lock.  
> I guess your empty implementation confuses Mac OS X a little bit,  
> which thinks the lock has succeded but isn’t going to UNLOCK since it  
> doesn’t know the lock token.

Well, I guess that’s fine for a single user webdav share 🙂

---

<div class="post-metadata">

**Author:** ![crux](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a6a055/32.png) [@crux](https://www.ruby-forum.com/u/crux)\
**Post date:** [January 1, 2007, 2:55pm UTC](https://www.ruby-forum.com/t/webrick-webdav-gem-served-files-are-mounted-only-read-only/74281/5 "2007-01-01T14:55:25Z")

</div>

Gabriele M. wrote:

> Well, I guess that’s fine for a single user webdav share 🙂

very well so! i took the time to pack the stuff and made it a gem so you  
can easily install it and serve your file directly from the the  
commandline.

[http://www.sofasportler.de/dirk.blog/2007/01/01/webdav-exporter-ruby-gem-serve-files-from-the-commandline/](http://www.sofasportler.de/dirk.blog/2007/01/01/webdav-exporter-ruby-gem-serve-files-from-the-commandline/)

many thanks for your help and who knows? maybe one day we might even  
sort out the DAV2 LOCK protocol issues. Until then,

thank you and happy new year
