Apache-SWIT

 view release on metacpan or  search on metacpan

META.yml  view on Meta::CPAN

abstract:           mod_perl server with integrated testing
author:
    - Boris Sukholitko (boriss@gmail.com)
license:            unknown
distribution_type:  module
configure_requires:
    ExtUtils::MakeMaker:  0
build_requires:
    ExtUtils::MakeMaker:  0
requires:
    Apache2::Cookie:      
    Apache2::Request:     
    Apache::Test:         
    Class::Accessor:      
    Class::DBI:           
    Class::DBI::Pg:       0.09
    Class::DBI::Pg::More:  0.04
    DBIx::VersionedSchema:  0.03
    Devel::NYTProf:       
    ExtUtils::ModuleMaker:  
    File::Slurp:          

Makefile.PL  view on Meta::CPAN

}}, } })->write_makefile(
    NAME         => 'Apache::SWIT',
    VERSION_FROM => 'lib/Apache/SWIT.pm', # finds $VERSION
    AUTHOR       => 'Boris Sukholitko (boriss@gmail.com)',
    ABSTRACT     => 'mod_perl server with integrated testing',
    EXE_FILES    => [ 'scripts/swit_init' ],
    PREREQ_PM    => { 'Test::Simple' => 0.44, 'Apache::Test' => '',
	'WWW::Mechanize' => '', 'Template' => '', 'HTML::Tested' => '0.48',
	'ExtUtils::ModuleMaker' => '', 'HTML::Tested::ClassDBI' => '0.21',
	'Apache2::Request' => '', 'Class::Accessor' => '', YAML => '',
	'Apache2::Cookie' => '', 'DBIx::VersionedSchema' => '0.03',
	'Test::TempDatabase' => '0.16', 'Class::DBI::Pg::More' => '0.04',
	'Class::DBI' => '', 'Class::DBI::Pg' => '0.09', 'File::Slurp' => '',
	'IPC::Run' => '', 'HTML::Tested::JavaScript' => '0.13'
	, 'Package::Alias' => '', 'Linux::Unshare' => ''
	, 'Queue::Worker' => '', 'IO::CaptureOutput' => ''
	, 'Linux::Smaps' => '', 'Devel::NYTProf' => ''
    },
);

lib/Apache/SWIT/Maker.pm  view on Meta::CPAN

	my $self = shift;
	my $rl = Apache::SWIT::Maker::Config->instance->root_location;
	my $an = Apache::SWIT::Maker::Config->instance->app_name;
	swmani_write_file('conf/httpd.conf.in', <<ENDM);
RewriteEngine on
RewriteRule ^/\$ $rl/index/r [R]
Alias $rl/www \@ServerRoot\@/public_html 
Alias /html-tested-javascript /usr/local/share/libhtml-tested-javascript-perl
# Format is:
# Remote IP, time, request, status, duration, referer, user agent
# PID, Cookie, total bytes in request, total bytes in response
LogFormat "%a %t \\"%r\\" %>s %D \\"%{Referer}i\\" \\"%{User-Agent}i\\" %P %{$an}C %I %O" switlog
ENDM
}

sub add_test {
	my ($self, $file, $number, $content) = @_;
	unless ($number) {
		$number = 1;
		$content = "BEGIN { use_ok('"
			. Apache::SWIT::Maker::Config->instance->root_class

lib/Apache/SWIT/Maker.pm  view on Meta::CPAN

	LoadModule apreq_module /usr/lib/apache2/modules/mod_apreq2.so
</IfModule>
<IfModule !rewrite_module.c>
	LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
</IfModule>
<IfModule !mod_deflate.c>
	LoadModule deflate_module /usr/lib/apache2/modules/mod_deflate.so
</IfModule>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript application/javascript application/xhtml+xml image/svg+xml

PerlModule Apache2::Request Apache2::Cookie Apache2::Upload Apache2::SubRequest
ENDS
}

sub regenerate_httpd_conf {
	my $self = shift;
	my $gq = Apache::SWIT::Maker::GeneratorsQueue->new;
	my $tree = Apache::SWIT::Maker::Config->instance;
	my ($sc, $rl) = ($tree->{session_class}, $tree->{root_location});
	my $ht_in = $self->gen_conf_header . <<ENDS;
PerlPostConfigRequire \@ServerRoot\@/conf/startup.pl

lib/Apache/SWIT/Session.pm  view on Meta::CPAN

sub access_handler($$) {
	my ($class, $r) = @_;
	my $session = $class->begin($r);
	$r->pnotes("SWITSession", $session);
	return Apache2::Const::OK();
}

sub begin {
	my ($class, $r) = @_;
	my %args = (_request => $r);
	my %cookies = Apache2::Cookie->fetch($r);
	$args{session_value} = $cookies{$class->cookie_name}->value
		if $cookies{$class->cookie_name};
	my $self = $class->new(%args);
	$self->read_stash;
	return $self;
}

sub request { return shift()->{_request}; }

sub end {
	my $self = shift;
	$self->write_stash;
	my $cookie = Apache2::Cookie->new($self->{_request}, 
			'-name' => $self->cookie_name,
			'-value' => $self->session_value);
	$cookie->path($self->{_request}->dir_config("SWITRootLocation") . ";HttpOnly");
	$cookie->bake($self->{_request});
}

sub new {
	my ($class, %args) = @_;
	return bless(\%args, $class);
}

t/100_session.t  view on Meta::CPAN

use strict;
use warnings FATAL => 'all';

use Test::More tests => 25;
use CGI::Cookie;
use Package::Alias 'Apache2::Cookie' => 'CGI::Cookie'
	, 'Apache2::Const::OK' => sub { 200; };

use_ok('Apache::SWIT::Session');

use Data::Dumper;
use Storable qw(thaw);

package Obj;

sub retrieve { return bless({}, shift()); }



( run in 0.309 second using v1.01-cache-2.11-cpan-4e96b696675 )