<%args> $file $content_type => undef <%init> use File::MimeInfo; use File::Basename; use URI::Escape; $file =~ s/___H___/#/g; $file = uri_unescape( $file ); my $mime_type = $content_type || mimetype($file); my $filename = basename( $file ); $m->autoflush('on'); $m->clear_buffer; ## `/bin/echo "$mime_type" >> /opt/rbc/logs/mime.log`; my $filesize = -s $file; $r->content_type("$mime_type"); $r->header_out('X-LIGHTTPD-send-file' => ("$file")); $r->header_out('Content-disposition' => ("attachment; filename=$filename; size=$filesize")); $m->autoflush('on'); return; binmode STDOUT; open my $fh => "$file"; binmode $fh; while(read $fh, my $buffer, 8192) { $m->print($buffer); ## $fh=*STDOUT; ## syswrite($fh, $buffer, 8192); $m->clear_buffer; } close $fh; $m->abort(); return;