Mind you, this is just quick code, a better perl hacker (LionsPhil?) should probably have a look at it.
#!/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>;
}
# 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
Cache-Control: max-age=0
Expires: Tue, 16 Aug 2005 18:14:23 GMT
END_HEADERS
# Send file
open(REPORT_FILE, $file);
while(<REPORT_FILE>) { print; }
close(REPORT_FILE);
exit 0;
Just replace /bin/cat in inetd.conf with whatever you save this as (make sure you chmod +x it ;)
It seems to work fine with most browsers, and IE gets the output. The funky think is that IE is echoing the headers, rather than using them. If I remove the headers, it only gets the file, but then the default text/html type takes over and makes it ugly.
I'll work on it a bit more.
pyro |