Skip Menu |

This queue is for tickets about the HTTP-Server-Simple-Static CPAN distribution.

Report information
The Basics
Id: 34068
Status: resolved
Priority: 0/
Queue: HTTP-Server-Simple-Static

People
Owner: sjq-perl [...] jadevine.org.uk
Requestors: bcbailey [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.06
Fixed in: (no value)



Subject: [PATCH] Don't try to serve directories
When HTTP::Server::Simple::Static->serve_static() is called for a path that resolves to a directory, it tries to serve it but sends no content. This is because the directory exists and IO::File does not complain when trying to open a directory (at least not on Linux), which is noted in its documentation. I suggest to instead use -f to check that the path is a file. Attached patch. Regards, Bradley C Bailey
Subject: http-server-simple-static-nodir.patch
diff -ruN HTTP-Server-Simple-Static-0.06.orig/lib/HTTP/Server/Simple/Static.pm HTTP-Server-Simple-Static-0.06/lib/HTTP/Server/Simple/Static.pm --- HTTP-Server-Simple-Static-0.06.orig/lib/HTTP/Server/Simple/Static.pm 2007-07-23 03:59:27.000000000 -0600 +++ HTTP-Server-Simple-Static-0.06/lib/HTTP/Server/Simple/Static.pm 2008-03-13 18:43:21.000000000 -0600 @@ -24,7 +24,7 @@ $path = $base . canonpath( URI::Escape::uri_unescape($path) ); my $fh = IO::File->new(); - if ( -e $path and $fh->open($path) ) { + if ( -f $path and $fh->open($path) ) { binmode $fh; binmode $self->stdout_handle;
On Thu Mar 13 20:57:42 2008, bcbailey wrote: Show quoted text
> When HTTP::Server::Simple::Static->serve_static() is called for a path > that resolves to a directory, it tries to serve it but sends no > content. This is because the directory exists and IO::File does not > complain when trying to open a directory (at least not on Linux), > which is noted in its documentation. > > I suggest to instead use -f to check that the path is a file. > Attached patch.
Thanks for the report, I have uploaded version 0.07 of HTTP::Server::Simple::Static with your suggested change. Stephen Quinney