+sub send_file {
+ my ($r,$file) = @_;
+ my $subr = $r->lookup_file($file);
+ $r->content_type($subr->content_type());
+ if ($::MP2) {
+ my $fileinfo = stat($file);
+
+ my $nonce = md5_base64($fileinfo->ino.$fileinfo->mtime);
+ if ($r->headers_in->{"If-None-Match"} eq $nonce) {
+ return Apache2::Const::HTTP_NOT_MODIFIED();
+ }
+
+ if ($r->headers_in->{"If-Modified-Since"} && str2time($r->headers_in->{"If-Modified-Since"}) < $fileinfo->mtime) {
+ return Apache2::Const::HTTP_NOT_MODIFIED();
+ }
+
+ $r->headers_out->{"Content-Length"} = $fileinfo->size;
+ $r->headers_out->{"Last-Modified-Date"} = time2str($fileinfo->mtime);
+ $r->headers_out->{"ETag"} = $nonce;
+ $r->sendfile($file);
+ return Apache2::Const::OK();
+ }
+ else {
+ $r->path_info('');
+ $r->filename($file);
+ return Apache::Constants::DECLINED();
+ }
+}
+