Silly wrong slash problem. I added the file size too, while I was at it. It seems to work fine with all the browsers I've tried here. Same caveats as the last post.
#!/usr/bin/perl
$|=1;
my $file = shift;
if(!$file) {
# Needs sanity checking, but this is just a quickie
print 'Usage: '.$0." <file>\n";
exit;
}
# Wait for HTTP request to finish
my $in_line = '';
while($in_line ne "\r\n") {
$in_line = <STDIN>;
}
# Load file
my $file_data = '';
open(REPORT_FILE, $file);
while(<REPORT_FILE>) { $file_data .= $_; }
close(REPORT_FILE);
my $file_size = length($file_data);
# 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: Tue, 16 Aug 2005 18:14:23 GMT
Last-Modified: Tue, 16 Aug 2005 18:14:23 GMT
Accept-Ranges: bytes
Connection: close
Content-Length: $file_size
Cache-Control: max-age=0
Expires: Tue, 16 Aug 2005 18:14:23 GMT
END_HEADERS
# Send file
print $file_data;
exit 0;
Let me know if it works for you.
pyro |