From: Kip H. <ki...@us...> - 2009-01-24 13:17:41
|
Update of /cvsroot/sawa/sawa/t/src/http/lib/http In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11548/t/src/http/lib/http Added Files: Base.pm handler.pm Log Message: Massive update to the test suite. Now decoupled from Apache::Test --- NEW FILE: Base.pm --- package http::Base; use SAWA::Constants; use SAWA::Event::Simple; our @ISA = qw( SAWA::Event::Simple ); sub registerEvents { return qw/ cookie headers multicookie redirect redirect_cookie/; } sub event_init { my $self = shift; my $ctxt = shift; $ctxt->{content} = '<html><body><p>Howdy</p></body></html>'; return OK; } sub event_cookie { my $self = shift; my $ctxt = shift; $self->cookie( -name =>'name', -value => 'val' ); return OK; } sub event_multicookie { my $self = shift; my $ctxt = shift; $self->cookie( -name =>'name1', -value => 'oreo' ); $self->cookie( -name =>'name2', -value => 'peanutbutter' ); return OK; } sub event_headers { my $self = shift; my $ctxt = shift; $self->mime_type('text/xml'); $self->charset('UTF-8'); $self->header( 'X-Wibble' => 'text/x-ubu' ); $self->header( Bogus => 'arbitrary' ); return OK; } sub event_redirect { my $self = shift; my $ctxt = shift; $self->redirect('/imnotthere'); return OK; } sub event_redirect_cookie { my $self = shift; my $ctxt = shift; $self->cookie( -name =>'name', -value => 'val' ); $self->redirect('/imnotthere'); return OK; } 1; --- NEW FILE: handler.pm --- package http::handler; use SAWA::Machine; use mod_perl; use constant MP2 => $mod_perl::VERSION >= 1.99; BEGIN { if (MP2) { require Apache::Response; require Apache::Const; } else { require Apache::Constants; require Apache::Request; } } sub handler { my $r = shift; my $app; if (MP1) { my $q = Apache::Request->instance( $r ); $app = SAWA::Machine->new({ -query => $q }); } else { $app = SAWA::Machine->new({ -query => $r }); } $app->pipeline( qw( http::Base basic::Output ) ); return $app->run({}); #return MP2 ? Apache::OK : Apache::Constants::OK; } 1; |