Apache-Mmap
view release on metacpan or search on metacpan
eg/MmapHandler.pm view on Meta::CPAN
unless( -f $filename ) {
## If the file referenced doesn't exist, we can't handle it.
return NOT_FOUND;
} else {
my $ctype = 'application/octet-stream'; # Default file type
## Set file type by extension
$ctype = 'image/gif' if $filename =~ /.gif$/i;
$ctype = 'image/jpeg' if $filename =~ /.jpe?g$/i;
$ctype = 'image/png' if $filename =~ /.png$/i;
## Set up OK headers and send them
$r->content_type( $ctype );
$r->send_http_header;
## Send file contents
$r->print( ${Apache::Mmap::mmap( $r->filename() )} );
## Return successfully
return OK;
eg/MmapHandler.pm view on Meta::CPAN
1; # Return something true for require
__END__
=head1 NAME
MmapHandler - Example Apache handler using Apache::Mmap
=head1 SYNOPSIS
<Files ~ "/some/htdocs/dir/images/.*(gif|jpe?g|png)$">
SetHandler perl-script
PerlHandler MmapHandler
</Files>
=head1 DESCRIPTION
This module is an example handler showing how Apache::Mmap can be
used. Any file requested will be mmap'd into the httpd's memory on
the first request. Subsequent requests will simply send the version
already in memory.
( run in 0.847 second using v1.01-cache-2.11-cpan-df04353d9ac )