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;