Tuesday 27 March 2007

MySource 4.0 WebDAV complete

Well, complete enough for the alpha release anyway. There is no authentication or permission checking in there, and you cant add and remove files and folders. I didn't leave these features out because they were hard, but because I don't want to finish planing this server without some feedback from users first. I have some ideas about how I want those features to work, so I'm interested to see if they go down well.

I'll write another post with my ideas in it later. This one is all about the fact that the server finally works. I didn't have to change any of the functionality to get it working on Windows, but it has been quite a wait to test it.

The problems I had were interesting.

First, I was using Lighttpd as the web server. Everything worked fine on OS X, but when saving a Word document on Windows, Lighttpd would receive a very specific GET request from Word and drop it. That is, it would return a 400 (bad request) error without ever asking by script to process the request. This caused Word to always open the file as read-only. There was nothing I could do about this error. I couldn't get Word to change the request and I couldn't get Lighttpd to accept it.

The server admins then set me up with Apache running the php5-cgi module (our Apache already runs mod-php4, so we couldn't just use mod-php5). Everything was working great with my existing saved connections until I tried creating a new connection for testing. The very first OPTIONS request that gets sent to see what version of the WebDAV protocol is being used was being handled by Apache without asking my script to process the request. Apparently, there was a bug in Apache where it handled the OPTIONS request for all CGI scripts. The version of Apache on our dev box could not be updated for a few weeks, so we had to find another way.

The solution turned out to be FastCGI on Apache. Every request made it through to my script and saving/browsing was working on both OS X and Windows XP.

It's been a long road, but the functionality this server provides will be a fantastic addition to MySource 4.0. I'm looking forward to trying it out on some real data when the alpha is released.