You can use Apache to do it but it's probably less efficient:

$lookup=$r->lookup_file($fullPathAndFilename);
$mime_type=$lookup->content_type();

but that does a full subrequest to my knowledge. I'd recommend a perl module that emulates the 'file' command:

use File::MimeInfo::Magic;
$mime_type=mimetype($fullPathAndFilename);

If you haven't used it before, note that Magic doesn't use the file extension, it checks content - 'man magic'

Finally if you are manually telling Apache to deliver a file from disk, make sure you update Apache's 'stat' info:

   if(stat($r->document_root.$r->uri)){
       my $filename=$r->document_root.$r->uri;
       $r->filename($filename);
$r->finfo(APR::Finfo::stat($filename, APR::Const::FINFO_NORM, $r->pool));
       return DECLINED; # fall back to Apache for normal file delivery
   }
   return NOT_FOUND;


John


Jeff Ambrosino wrote:

Through my MP2 handler, I need to be able to set Content-Type based on

Reply via email to