HTTP::DAVServer::PUT - Implements the PUT method


HTTP-DAVServer documentation Contained in the HTTP-DAVServer distribution.

Index


Code Index:

NAME

Top

HTTP::DAVServer::PUT - Implements the PUT method

SUPPORT

Top

For technical support please email to jlawrenc@cpan.org ... for faster service please include "HTTP::DAVServer" and "help" in your subject line.

AUTHOR

Top

 Jay J. Lawrence - jlawrenc@cpan.org
 Infonium Inc., Canada
 http://www.infonium.ca/

COPYRIGHT

Top

ACKNOWLEDGEMENTS

Top

Thank you to the authors of my prequisite modules. With out your help this code would be much more difficult to write!

 XML::Simple - Grant McLean
 XML::SAX    - Matt Sergeant
 DateTime    - Dave Rolsky

Also the authors of litmus, a very helpful tool indeed!

SEE ALSO

Top

HTTP::DAV, HTTP::Webdav, http://www.webdav.org/, RFC 2518


HTTP-DAVServer documentation Contained in the HTTP-DAVServer distribution.

package HTTP::DAVServer::PUT;

our $VERSION=0.1;

use strict;
use warnings;

sub handle {

    my ($self, $r, $url, $responder, $request) = @_;

	my $fullpath = $HTTP::DAVServer::ROOT . $url;
    $url =~ m#^(.*)/([^/]+)$#;
    my $path     = $HTTP::DAVServer::ROOT . $1;
    my $file     = $2;

    if ( -d $fullpath ) {
        $responder->conflict( $r, "PUTONCOLL");
    }
    unless ( -d $path ) {
        $responder->conflict( $r, "PUTNODIR");
    }

    my $exists = -f $fullpath ? 1 : 0;

    # XXX Not checking for content-* headers => 501 Not Implemented error

    open FOUT, ">$fullpath" or $responder->forbidden( $r, "PUTDENY" );
    local undef $/;
    print FOUT <>;

    close FOUT or $responder->diskFull( $r, "PUTFULL" );

    if ($exists) {
        $responder->ok( $r, "PUT" );
    } else {
        $responder->created( $r, "PUT" );
    }


}


1;