make mod_perl request object a global in PLP::Apache only
[perl/plp/.git] / PLP / Apache.pm
index c3880957e7a405ad9a34dc4ad37d1207eacbf718..6b28f949f1f0b6fd1b9ff7e6c6bc0313d148d4eb 100644 (file)
@@ -21,11 +21,14 @@ BEGIN {
        }
 }
 
+our $r;
+
 # mod_perl initializer: returns 0 on success, Apache error code on failure
 sub init {
-       our $r = shift;
+       $r = shift;
 
        $PLP::print = 'PLP::Apache::print';
+       $PLP::read = \&read;
        
        $ENV{PLP_FILENAME} = my $filename = $r->filename;
        
@@ -49,11 +52,17 @@ sub init {
        return 0; # OK
 }
 
+sub read ($) {
+       my ($bytes) = @_;
+       $r->read(my $data, $bytes);
+       return $data;
+}
+
 # FAST printing under mod_perl
 sub print {
        return unless grep length, @_;
        PLP::sendheaders() unless $PLP::sentheaders;
-       $PLP::Apache::r->print(@_);
+       $r->print(@_);
 }
 
 # This is the mod_perl handler.