my $full = "$server::base_dir/tftp/$path";
+ if ( $path ne '/' && -d $full ) {
+
+ # redirect directory to end with /
+ if ( $path !~ m{/$} ) {
+ print $client "HTTP/1.0 301 Moved Permanently\r\nLocation: $path/\r\n\r\n";
+ close($client);
+ return 1;
+ }
+
+ # display directory index
+ print $client "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nConnection: close\r\n\r\n";
+ print $client qq{<ul>\n};
+ foreach my $path ( map { s{$full/}{}; $_ } glob "$full/*" ) {
+ print $client qq{<li><a href="$path">$path</a></li>\n};
+ }
+ print $client qq{</ul>\n};
+ close($client);
+ return 1;
+ }
+
return if ! -f $full;
return if $full =~ m{\.ico$};