#!/usr/bin/perl
$|=1;
$nowdate = `date +'%a, %d %b %Y %T %Z'`
my $file = shift;
if(!$file) {
# Needs sanity checking, but this is just a quickie
print 'Usage: '.$0." <file>\n";
exit;
}
$filedate = `date +'%a, %d %b %Y %T %Z' -r`
# Wait for HTTP request to finish
my $in_line = '';
while($in_line ne "\r\n") {
$in_line = <STDIN>;
}
# Send HTTP response headers
print <<'END_HEADERS';
HTTP\1.1 200 OK
Server: reportsock/1.0 16aug2005
Content-Type: text/plain; charset=iso-8859-1
Date: $nowdate
Last-Modified: $filedate
Accept-Ranges: bytes
Connection: close
Cache-Control: max-age=0
Expires: $nowdate
END_HEADERS
# Send file
open(REPORT_FILE, $file);
while(<REPORT_FILE>) { print; }
close(REPORT_FILE);
exit 0;
|