| 1 | package Apache::PassExec; | ||
| 2 | use Apache::Constants ':common'; | ||
| 3 | use FileHandle; | ||
| 4 | use strict; | ||
| 5 | use vars qw($VERSION $BUFFERSIZE); | ||
| 6 | $BUFFERSIZE = 16384; | ||
| 7 | |||
| 8 | $VERSION = "0.05"; | ||
| 9 | |||
| 10 | sub BUFFERSIZE { | ||
| 11 | my($self,$new) = @_; | ||
| 12 | $new += 0 if $new; | ||
| 13 | $BUFFERSIZE = $new || $BUFFERSIZE || 16384; | ||
| 14 | } | ||
| 15 | |||
| 16 | sub handler { | ||
| 17 | my $r = shift; | ||
| 18 | my $filename = $r->filename(); | ||
| 19 | my $fh; | ||
| 20 | |||
| 21 | if (-f $filename and | ||
| 22 | -x _ and | ||
| 23 | $fh = FileHandle->new("$filename |")) { | ||
| 24 | print STDERR "$filename |\n"; | ||
| 25 | my $headers; | ||
| 26 | { local $/ = "\n\n"; | ||
| 27 | $headers = <$fh>; $r->send_cgi_header($headers); } | ||
| 28 | |||
| 29 | my $buf; | ||
| 30 | local $\; | ||
| 31 | |||
| 32 | while (defined($buf = <$fh>)){ | ||
| 33 | print $buf; | ||
| 34 | } | ||
| 35 | $fh->close; | ||
| 36 | return OK; | ||
| 37 | } else { | ||
| 38 | return NOT_FOUND; | ||
| 39 | } | ||
| 40 | } | ||
| 41 | |||
| 42 | 1; | ||
| 43 | |||
| 44 | __END__ |