Enabling WebDAV in IIS for HTTP PUT support
I spent a good portion of today trying to get a WebDAV share set up on a Windows Server 2003 machine. This machine is a test environment for a web service that accepts information about book titles from clients, including cover images. We decided to use the HTTP PUT method for uploading the image files, instead of HTTP POST or FTP, to keep things as simple as possible — we didn’t want to write a POST acceptor (or use someone else’s) or switch protocols mid-transmission. HTTP PUT is implemented through WebDAV in IIS, so getting WebDAV working was the first step.
Because IIS 6 comes with everything turned off by default, you have to enable the WebDAV “extension” to have PUT work. This really got me. IIS lets you create a WebDAV virtual directory and even access and browse it via HTTP, but a PUT request returns a “501: Not implemented” error until the extension is allowed. I scratched my head for a while before realizing what the problem was.
So, in sum, the steps to set up WebDAV are:
- Enable the WebDAV extension on the Web Service Extensions detail pane in IIS.
- Create a filesystem directory for a WebDAV share. Set the NTFS permissions appropriately.
- Create a virtual directory in IIS that points to the filesystem directory.
- Set the IIS directory security appropriately. Microsoft recommends not using integrated Windows authentication for internet-accessible shares.
- Start making PUT requests!
The final step might be a bit tricky if you haven’t written any programs to make HTTP requests (I certainly hadn’t), since I’m not sure what browser support for PUT there is. Fortunately, I found this nifty Python script to make HTTP PUT requests, and everything seems to be working beautifully. Many thanks to Sean B. Palmer, the author!
More and more these days, I find something is easier when I try to do it with Python. Now if only I could get someone to pay me for it.