The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Apache::WebDAV - Extensible WebDAV server for Apache.

SYNOPSIS

  use Apache::WebDAV;

ABSTRACT

Write perl modules to handle file transfers through WebDAV.

DESCRIPTION

Apache::WebDAV is a WebDAV server implementation. It was originally based on Net::DAV::Server (which isn't compatible with Apache), but has undergone significant architectural changes. Apache::WebDAV can be used with a simple mod_perl handler and tied to Filesys::Virtual::Plain to provide a simple, file-system-based WebDAV server. However, the real power of this module lies in its ability to use any Filesys::Virtual subclass as a storage mechanism. For example, you can write a subclass of Filesys::Virtual to store and retrieve data directly from a database.

It is also possible to use different Filesys::Virtual subclasses to respond to different paths under your WebDAV root. This allows you to have some sections interact with the filesystem, others with a database, etc.

WebDAV Standards Compatibility

The WebDAV protocol is unclear and client behavior differs drastically. During development of this module, the following clients were identified as targets for support:

 WebDrive  (windows)
 Transmit  (osx)
 Goliath   (osx)
 Cadaver   (linux)
 Konqueror (linux)
 HTTP::DAV (perl)

The MacOSX Finder is also supported, assuming your Filesys::Virtual subclass is fully and correctly implemented. Specifically, you can't expect the Finder to "PUT" a file in one nice step, rather, it takes multiple requests and it's difficult to programmatically determine when the file is "finished" uploading.

In addition, depending on your Filesys::Virtual subclass, of course, this module passes most of the WebDAV Litmus tests (http://www.webdav.org/neon/litmus/) without errors or warnings. Specifically:

 OPTIONS for DAV: header 
 PUT, GET with byte comparison 
 MKCOL 
 DELETE (collections, non-collections) 
 COPY, MOVE using combinations of: 
  overwrite t/f 
  destination exists/doesn't exist 
  collection/non-collection

However, there is currently no support for LOCKING or PROPERTY MANIPULATION.

Finally, there are certain pieces of code in this module that purposefully break from the WebdAV protocol in order to support a specific client. As of this writing, both Goliath and WebDrive require these hacks. (Both are commented in the code.)

Microsoft Internet Explorer "Web Folders" do not seem to work and no effort has been made to figure out why.

Here is the output of the Litmus Test when running basic, copymove, and http:

    $ echo $TESTS
    basic copymove http
    lozier@ruggles:~$ litmus http://pg.ruggles:8080/ApacheDAV
    -> running `basic':
     0. init.................. pass
     1. begin................. pass
     2. options............... pass
     3. put_get............... pass
     4. put_get_utf8_segment.. pass
     5. mkcol_over_plain...... pass
     6. delete................ pass
     7. delete_null........... pass
     8. delete_fragment....... WARNING: DELETE removed collection resource with Request-URI including fragment; unsafe
        ...................... pass (with 1 warning)
     9. mkcol................. pass
    10. mkcol_again........... pass
    11. delete_coll........... pass
    12. mkcol_no_parent....... pass
    13. mkcol_with_body....... pass
    14. finish................ pass
    <- summary for `basic': of 15 tests run: 15 passed, 0 failed. 100.0%
    -> 1 warning was issued.
    -> running `copymove':
     0. init.................. pass
     1. begin................. pass
     2. copy_init............. pass
     3. copy_simple........... pass
     4. copy_overwrite........ pass
     5. copy_nodestcoll....... pass
     6. copy_cleanup.......... pass
     7. copy_coll............. pass
     8. move.................. pass
     9. move_coll............. pass
    10. move_cleanup.......... pass
    11. finish................ pass
    <- summary for `copymove': of 12 tests run: 12 passed, 0 failed. 100.0%
    -> running `http':
     0. init.................. pass
     1. begin................. pass
     2. expect100............. pass
     3. finish................ pass
    <- summary for `http': of 4 tests run: 4 passed, 0 failed. 100.0%

The props tests mostly fail.

IMPLEMENTATION

In order to get a working WebDAV server up and running quickly, the following instructions are provided. It is recommended that you install Filesys::Virtual::Plain and follow the instructions below. Please be advised that there is no authentication layer built in, so don't just put this out on a public server somewhere and expect it to be secure! Rather, write your own mod_perl authentication handler.

mod_perl handler

My theoretical server is "myserver" in all examples. First you need to write a simple mod_perl handler. Mine is called DAVHandler.pm. The code looks like this:

 package DAVHandler;

 use strict;
 use warnings;

 use Apache::WebDAV;
 use Filesys::Virtual::Plain;

 sub handler
 {
     my $r = shift;

     my $dav = new Apache::WebDAV();

     my @handlers = (
         {
             path   => '/DAV',
             module => 'Filesys::Virtual::Plain',
             args   => {
                 root_path => '/home/lozier'
             }
         }
     );

     $dav->register_handlers(@handlers);

     return $dav->process($r);
 }

Many Filesys::Virtual subclasses require arguments to their constructors. Notice the "args" subscript in the @handlers array above. Use this to pass any required arguments. If no arguments are present, the root_path will be set to the path that was matched ($handlers[0]->{'path'} in this example), and cwd will be set to the full URI (from $r->uri()).

Apache Configuration

You will need to tell your apache server to respond to webdav requests on a specific path. Here is a full example of the required section:

 <Location /DAV>
     SetHandler perl-script
     PerlHandler Finch::Web::Handler::ApacheDAV
 </Location>

Please note, this example doesn't have any authentication requirement. Please use a mod_perl authentication handler to allow valid users only.

UNIT TESTS

Since this module requires a running instance of Apache with a properly configured mod_perl handler in order to even run, there are no unit tests provided. Feedback requested.

SEE ALSO

Filesys::Virtual Filesys::Virtual::Plain Net::DAV::Server HTTP::DAV

AUTHOR

Brian Lozier, Geospiza, Inc. lozier@geospiza.com

COPYRIGHT AND LICENSE

Copyright (C) 2006 Geospiza, Inc. http://www.geospiza.com/

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.