Skip Menu |

This queue is for tickets about the Net-DAV-Server CPAN distribution.

Report information
The Basics
Id: 11848
Status: resolved
Priority: 0/
Queue: Net-DAV-Server

People
Owner: Nobody in particular
Requestors: ms419 [...] freezone.co.uk
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.24
Fixed in: (no value)



Subject: [PATCH] PROPFIND body support, POE::Component::Server::HTTP support
Finished the support for parsing PROPFIND request bodies - for retreiving property names, named properties, or all properties. Also, tweeked some things to support publishing DAV using POE::Component::Server::HTTP (bug #11821) Basically, P::C::S::H handlers can't return new HTTP::Responses - they must modify the HTTP::Response which P::C::S::H passes by reference. Net::DAV::Server already passes HTTP::Response to each method - this patch enables HTTP::Response to get passed to N::D::S::run - & tweeks methods to modify the supplied HTTP::Response, rather than create new ones. P::C::S::H also needed - - my $path = uri_unescape($request->uri); + my $path = uri_unescape($request->uri->path); Successfully tested with both P::C::S::H & HTTP::Daemon Thanks for Net::DAV::Server - WebDAV is the mega rad! Jack

Message body is not shown because it is too large.

From: ms419 [...] freezone.co.uk
A little more magic to make wide character file names work - I still don't totally get Perl & Unicode (despite perluiintro) - so I can't say what uri_unescape returns, that it must be converted to/from UTF-8 - Anyway, I've many files with international characters & this works well with OS X WebDAVFS, Safari, & Firefox (if Firefox is set to UTF-8 - Firefox doesn't respect 'Content-Type: ... ; charset="utf-8"'?) Thanks again for Net::DAV::Server - it's the best! Jack
--- Server.pm 2005/03/12 04:40:16 1.5 +++ Server.pm 2005/03/13 16:50:52 @@ -2,7 +2,7 @@ use strict; use warnings; use File::Slurp; -use Encode qw(encode_utf8); +use Encode; use File::Find::Rule::Filesys::Virtual; use HTTP::Date; use HTTP::Headers; @@ -45,7 +45,7 @@ my $fs = $self->filesys || die 'Boom'; my $method = $request->method; - my $path = uri_unescape($request->uri->path); + my $path = decode_utf8 uri_unescape $request->uri->path; if (!defined $response) { $response = HTTP::Response->new; @@ -68,19 +68,17 @@ sub options { my($self, $request, $response) = @_; - #no warnings; - #$response->headers->header('DAV' => [qw(1,2 <http://apache.org/dav/propset/fs/1>)]); # Nautilus freaks out - $response->headers->header('DAV' => '1,2,<http://apache.org/dav/propset/fs/1>'); # Nautilus freaks out - $response->headers->header('MS-Author-Via' => 'DAV'); # Nautilus freaks out - $response->headers->header('Allow' => join(',', map {uc} keys %implemented)); - $response->headers->header('Content-Type' => 'httpd/unix-directory'); - $response->headers->header('Keep-Alive' => 'timeout=15, max=96'); + $response->header('DAV' => '1,2,<http://apache.org/dav/propset/fs/1>'); # Nautilus freaks out + $response->header('MS-Author-Via' => 'DAV'); # Nautilus freaks out + $response->header('Allow' => join(',', map {uc} keys %implemented)); + $response->header('Content-Type' => 'httpd/unix-directory'); + $response->header('Keep-Alive' => 'timeout=15, max=96'); return $response; } sub head { my($self, $request, $response) = @_; - my $path = uri_unescape($request->uri->path); + my $path = decode_utf8 uri_unescape $request->uri->path; my $fs = $self->filesys; if ($fs->test("f", $path) && $fs->test("r", $path)) { @@ -90,7 +88,7 @@ } elsif ($fs->test("d", $path)) { # a web browser, then my @files = $fs->list($path); - $response->header('Content-Type', 'text/html'); + $response->header('Content-Type' => 'text/html; charset="utf-8"'); } else { $response = HTTP::Response->new(404, "NOT FOUND", $response->headers); } @@ -99,28 +97,28 @@ sub get { my($self, $request, $response) = @_; - my $path = uri_unescape($request->uri->path); + my $path = decode_utf8 uri_unescape $request->uri->path; my $fs = $self->filesys; - if ($fs->test("f", $path) && $fs->test("r", $path)) { + if ($fs->test('f', $path) && $fs->test('r', $path)) { my $fh = $fs->open_read($path); my $file = join '', <$fh>; $fs->close_read($fh); $response->content($file); $response->last_modified($fs->modtime($path)); - } elsif ($fs->test("d", $path)) { + } elsif ($fs->test('d', $path)) { # a web browser, then my @files = $fs->list($path); my $body; foreach my $file (@files) { - if ($fs->test("d", "$path$file")) { + if ($fs->test('d', $path . $file)) { $body .= qq|<a href="$file/">$file/</a><br>\n|; } else { $file =~ s{/$}{}; $body .= qq|<a href="$file">$file</a><br>\n|; } } - $response->header('Content-Type' => 'text/html'); + $response->header('Content-Type' => 'text/html; charset="utf-8"'); $response->content($body); } else { $response->code(404); @@ -131,7 +129,7 @@ sub put { my($self, $request, $response) = @_; - my $path = uri_unescape($request->uri->path); + my $path = decode_utf8 uri_unescape $request->uri->path; my $fs = $self->filesys; $response = HTTP::Response->new(201, "CREATED", $response->headers); @@ -153,7 +151,7 @@ sub delete { my($self, $request, $response) = @_; - my $path = uri_unescape($request->uri->path); + my $path = decode_utf8 uri_unescape $request->uri->path; my $fs = $self->filesys; unless ($fs->test("e", $path)) { @@ -200,7 +198,7 @@ sub copy { my($self, $request, $response) = @_; - my $path = uri_unescape($request->uri->path); + my $path = decode_utf8 uri_unescape $request->uri->path; my $fs = $self->filesys; my $destination = $request->header('Destination'); @@ -268,7 +266,7 @@ sub copy_file { my($self, $request, $response) = @_; - my $path = uri_unescape($request->uri->path); + my $path = decode_utf8 uri_unescape $request->uri->path; my $fs = $self->filesys; my $destination = $request->header('Destination'); @@ -327,7 +325,7 @@ sub lock { my($self, $request, $response) = @_; - my $path = uri_unescape($request->uri->path); + my $path = decode_utf8 uri_unescape $request->uri->path; my $fs = $self->filesys; $fs->lock($path); @@ -337,7 +335,7 @@ sub unlock { my($self, $request, $response) = @_; - my $path = uri_unescape($request->uri->path); + my $path = decode_utf8 uri_unescape $request->uri->path; my $fs = $self->filesys; $fs->unlock($path); @@ -347,7 +345,7 @@ sub mkcol { my($self, $request, $response) = @_; - my $path = uri_unescape($request->uri->path); + my $path = decode_utf8 uri_unescape $request->uri->path; my $fs = $self->filesys; if ($request->content) { @@ -369,13 +367,13 @@ sub propfind { my($self, $request, $response) = @_; - my $path = uri_unescape($request->uri->path); + my $path = decode_utf8 uri_unescape $request->uri->path; my $fs = $self->filesys; my $depth = $request->header('Depth'); my $reqinfo = 'allprop'; my @reqprops; - if ($request->headers->header('Content-Length')) { + if ($request->header('Content-Length')) { my $content = $request->content; my $parser = XML::LibXML->new; my $doc; @@ -405,7 +403,7 @@ $response->code(207); $response->message('Multi-Status'); - $response->headers->header('Content-Type' => 'text/xml; charset="utf-8"'); + $response->header('Content-Type' => 'text/xml; charset="utf-8"'); my $doc = XML::LibXML::Document->new('1.0', 'utf-8'); my $multistat = $doc->createElement('D:multistatus');
Thanks, these are in Net-DAV-Server-1.25