Subject: | Return a proper mime type on GET and PROPFIND |
HEAD and GET file requests, GET html dir listings and PROPFIND should
return a proper mime-type for files, for example with a call to
_get_mime($path,'application/octet-stream')
sub _get_mime {
my $path = shift;
my $fallback = shift;
# patch1: I don't know if this breaks WebDAV RFC, but let's
# try to return an actual mime type
my $mt = MIME::Types->new;
my $mime = $mt->mimeTypeOf($path);
# also possible to detect mime with:
# my $mime = LWP::MediaTypes::guess_media_type($path);
# or
# # File::MMagic
if($mime){
return $mime;
}else{
if($fallback){
return $fallback;
}else{
return 'httpd/unix-file';
}
}
}