DAVServer/PUT.pm untested

filter: Statementstmt 0.0% 0 / 24 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 3 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 46 CC 5 SCAR 30.9
CC
5
Cov
0%
handle
30.0
BEGIN
2.0
BEGIN
2.0
CRAP 22.0
1  
2  
3 package HTTP::DAVServer::PUT;
4  
5 our $VERSION=0.1;
6  
7 use strict;
8 use warnings;
9  
10 =head1 NAME
11  
12 HTTP::DAVServer::PUT - Implements the PUT method
13  
14 =cut
15  
16 sub handle {
17  
18 my ($self, $r, $url, $responder, $request) = @_;
19  
20 my $fullpath = $HTTP::DAVServer::ROOT . $url;
21 $url =~ m#^(.*)/([^/]+)$#;
22 my $path = $HTTP::DAVServer::ROOT . $1;
23 my $file = $2;
24  
25 if ( -d $fullpath ) {
26 $responder->conflict( $r, "PUTONCOLL");
27 }
28 unless ( -d $path ) {
29 $responder->conflict( $r, "PUTNODIR");
30 }
31  
32 my $exists = -f $fullpath ? 1 : 0;
33  
34 # XXX Not checking for content-* headers => 501 Not Implemented error
35  
36 open FOUT, ">$fullpath" or $responder->forbidden( $r, "PUTDENY" );
37 local undef $/;
38 print FOUT <>;
39  
40 close FOUT or $responder->diskFull( $r, "PUTFULL" );
41  
42 if ($exists) {
43 $responder->ok( $r, "PUT" );
44 } else {
45 $responder->created( $r, "PUT" );
46 }
47  
48  
49 }
50  
51  
52 =head1 SUPPORT
53  
54 For technical support please email to jlawrenc@cpan.org ...
55 for faster service please include "HTTP::DAVServer" and "help" in your subject line.
56  
57 =head1 AUTHOR
58  
59 Jay J. Lawrence - jlawrenc@cpan.org
60 Infonium Inc., Canada
61 http://www.infonium.ca/
62  
63 =head1 COPYRIGHT
64  
65 Copyright (c) 2003 Jay J. Lawrence, Infonium Inc. All rights reserved.
66 This program is free software; you can redistribute
67 it and/or modify it under the same terms as Perl itself.
68  
69 The full text of the license can be found in the
70 LICENSE file included with this module.
71  
72 =head1 ACKNOWLEDGEMENTS
73  
74 Thank you to the authors of my prequisite modules. With out your help this code
75 would be much more difficult to write!
76  
77 XML::Simple - Grant McLean
78 XML::SAX - Matt Sergeant
79 DateTime - Dave Rolsky
80  
81 Also the authors of litmus, a very helpful tool indeed!
82  
83 =head1 SEE ALSO
84  
85 HTTP::DAV, HTTP::Webdav, http://www.webdav.org/, RFC 2518
86  
87 =cut
88  
89 1;
90