CGI-ExtDirect
view release on metacpan or search on metacpan
examples/p5httpd view on Meta::CPAN
# cat "relative/path", "text/html", $method; writes the appropriate
# response headers to STDOUT. If $method == GET (which is the default)
# then the file is dumped on STDOUT as well.
sub cat($$;$) {
my ( $file, $mimetype, $method ) = @_;
$method = "GET" unless $method;
my $fullpath = "$server_root$file";
my ( undef, undef, undef, undef, undef, undef, undef, $length, undef, $mtime )
= stat($fullpath);
$mtime = gmtime $mtime;
my ( $day, $mon, $dm, $tm, $yr ) =
( $mtime =~ m/(...) (...) (..) (..:..:..) (....)/ );
print Client "Content-length: $length\n";
print Client "Last-Modified: $day, $dm $mon $yr $tm GMT\n";
print Client "Content-type: $mimetype\n\n";
my $sent = 0;
if ( $method eq "GET" ) {
local $INPUT_RECORD_SEPARATOR = undef; # gobble whole files, but only here
( run in 0.923 second using v1.01-cache-2.11-cpan-49f99fa48dc )