package Handler;
use strict;
use Apache ();
use Apache::Constants qw(:common &OPT_EXECCGI &REDIRECT);

sub handler 
{
    my $r = shift;
    if(ref $r) 
    {
	$r->request($r);
    }
    else 
    {
	$r = Apache->request;
    }

    warn "In Fixuphandler\n";
    Apache->push_handlers("PerlHandler", \&PH);

    my $Module = __PACKAGE__;
    my $File_base = "/tmp/$Module";
    $File_base =~ s/::/-/g;
#    open(OLDOUT, ">&STDOUT");  # Save real STDOUT
#    open (STDOUT,">${File_base}-out-$$");

    untie *STDOUT;

    return DECLINED;
}

sub PH 
{ 
    my $r = shift;
    warn "In PH2!\n";  
#    $r->content_type("text/plain");
#    $r->send_http_header;
#    $r->print("In PH2\n"); 

#    close STDOUT;
#    open( STDOUT, ">&OLDOUT" );


    $r->send_http_header;
    $r->print("In PH2\n"); 

    return OK;
}


1;

