| 1 | package # Hide from CPAN indexer | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | POE::Component::XUL; | ||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # $Id: XUL.pm 1566 2010-11-03 03:13:32Z fil $ | ||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # Copyright Philip Gwyn 2007-2010. All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 14 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 14 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 14 | ▶ | use File::Path; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 14 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 14 | ▶ | use File::Basename; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 14 | ▶ | use HTTP::Date; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 14 | ▶ | use HTTP::Status; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 14 | ▶ | use HTML::Entities qw( encode_entities_numeric ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 14 | ▶ | use I18N::AcceptLanguage; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 14 | ▶ | use IO::File; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 14 | ▶ | use MIME::Types; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 14 | ▶ | use POE; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 14 | ▶ | use POE::Component::Server::HTTP; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 14 | ▶ | use POE::Session; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 14 | ▶ | use POE::XUL::Controler; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 14 | ▶ | use POE::XUL::Node; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 14 | ▶ | use POE::XUL::Request; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 14 | ▶ | use POE::XUL::Logging; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 14 | ▶ | use POSIX qw(:errno_h); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 14 | ▶ | use Scalar::Util qw( reftype blessed ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 14 | ▶ | use Socket qw( unpack_sockaddr_in ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 14 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 14 | our $VERSION = '0.0600'; | |||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 14 | ▶ | use constant DEBUG => 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 14 | ▶ | use vars qw( $HAVE_DEVEL_SIZE $HAVE_DATA_DUMPER $SINGLETON ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 14 | ▶ | $HAVE_DEVEL_SIZE = 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 14 | ▶ | eval "use " . # Hide from CPANTS kwalitee | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 39 | "Devel::Size;"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 14 | ▶ | $HAVE_DEVEL_SIZE = 1 unless $@; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 14 | $HAVE_DATA_DUMPER = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 43 | 14 | ▶ | eval "use Data::Dumper;"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 14 | ▶ | $HAVE_DATA_DUMPER = 1 unless $@; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||
| 47 | ############################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 48 | sub spawn | ||||||||||||||||||||||||||||||||||||||||||||||
| 49 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 2 | ▶ | my ($package, $args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
spawn: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 2 | my $self = $package; | |||||||||||||||||||||||||||||||||||||||||||||
| 53 | 2 | ▶ | unless( blessed $self ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 2 | $self = $package->new( $args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||
| 57 | POE::Session->create( | ||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 2 | ▶ | options => { %{ $self->{opts}||{} } }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | object_states => [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 60 | $self => [ qw( _start shutdown | ||||||||||||||||||||||||||||||||||||||||||||||
| 61 | static xul httpd_error xul_file | ||||||||||||||||||||||||||||||||||||||||||||||
| 62 | poe_size poe_kernel poe_test | ||||||||||||||||||||||||||||||||||||||||||||||
| 63 | session_count session_timeout session_exists | ||||||||||||||||||||||||||||||||||||||||||||||
| 64 | sig_HUP sig_DIE | ||||||||||||||||||||||||||||||||||||||||||||||
| 65 | ) ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 66 | ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 67 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | ############################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 71 | sub new | ||||||||||||||||||||||||||||||||||||||||||||||
| 72 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 6 | ▶ | my( $package, $args ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=11 SCAR=26.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 6 | $args->{port} = $args->{port}; | |||||||||||||||||||||||||||||||||||||||||||||
| 76 | 6 | ▶ | $args->{port} = 8077 unless defined $args->{port}; # PORT | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 6 | ▶ | $args->{root} = $args->{root} || '/usr/local/poe-xul/xul'; # ROOT | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args->{'root'} || '/usr/local/poe-xul/xul'
MC/DC0%0/1
$args->{'root'} || '/usr/local/poe-xul/xul'
$args->{'root'}
Truth table50%1/2
A
A= $args->{'root'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 6 | ▶ | $args->{alias} ||= 'component-poe-xul'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args->{"alias"} ||= "component-poe-xul"
MC/DC100%1/1
$args->{"alias"} ||= "component-poe-xul"
$args->{"alias"}
Truth table100%2/2
A
A= $args->{"alias"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 6 | ▶ | $args->{apps} = {} if (!defined $args->{apps}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 6 | ▶ | $args->{opts} = {} if (!defined $args->{opts}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 6 | ▶ | $args->{timeout} ||= 60*30; # 30 minutes | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args->{"timeout"} ||= 1800
MC/DC0%0/1
$args->{"timeout"} ||= 1800
$args->{"timeout"}
Truth table50%1/2
A
A= $args->{"timeout"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 6 | ▶ | unless (ref($args->{apps}) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | croak "apps parameter must be a HASH ref"; | |||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 6 | ▶ | unless (ref($args->{opts}) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | croak "opts parameter must be a HASH ref"; | |||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 6 | my $self = bless { %$args }, $package; | |||||||||||||||||||||||||||||||||||||||||||||
| 91 | 6 | $self->build_controler( $self->{timeout}, $self->{apps} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 6 | $self->__parse_apps(); | |||||||||||||||||||||||||||||||||||||||||||||
| 94 | 6 | $self->{sessions} = {}; | |||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 6 | ▶ | $self->{static_root} ||= File::Spec->catfile( $self->{root}, 'xul' ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"static_root"} ||= "File::Spec"->catfile($self->{"root"}, "xul")
MC/DC0%0/2
$self->{"static_root"} ||= "File::Spec"->catfile($self->{"root"}, "xul")
$self->{"static_root"}
"File::Spec"->catfile($self->{"root"}, "xul")
Truth table33%1/3
A ||= B
A= $self->{"static_root"}B= "File::Spec"->catfile($self->{"root"}, "xul")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 6 | ▶ | $self->{log_root} ||= File::Spec->catfile( $self->{root}, 'log' ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"log_root"} ||= "File::Spec"->catfile($self->{"root"}, "log")
MC/DC0%0/2
$self->{"log_root"} ||= "File::Spec"->catfile($self->{"root"}, "log")
$self->{"log_root"}
"File::Spec"->catfile($self->{"root"}, "log")
Truth table33%1/3
A ||= B
A= $self->{"log_root"}B= "File::Spec"->catfile($self->{"root"}, "log")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 6 | $self->build_logging( $args->{logging} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 6 | $self->{languages} = [ qw( en fr ) ]; # XXX | |||||||||||||||||||||||||||||||||||||||||||||
| 102 | 6 | $self->{default_language} = 'fr'; # XXX | |||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 6 | return $SINGLETON = $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||
| 107 | sub __parse_apps | ||||||||||||||||||||||||||||||||||||||||||||||
| 108 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 6 | ▶ | my( $self ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__parse_apps: called CC=10 SCAR=42.6
| |||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 6 | my $controler = $self->{controler}; | |||||||||||||||||||||||||||||||||||||||||||||
| 112 | 6 | ▶ | $self->{app_names} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"app_names"} ||= {}
MC/DC0%0/1
$self->{"app_names"} ||= {}
$self->{"app_names"}
Truth table50%1/2
A
A= $self->{"app_names"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 6 | foreach my $app ( keys %{ $self->{apps} } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | my $A = $self->{apps}{$app}; | |||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my $r = ref $A; | |||||||||||||||||||||||||||||||||||||||||||||
| 117 | # Make sure we have a package or a coderef | ||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | my $ok = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | if( $r and 'HASH' eq $r ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$r and "HASH" eq $r
MC/DC0%0/2
$r and "HASH" eq $r
$r
"HASH" eq $r
Truth table0%0/3
A and B
A= $rB= "HASH" eq $r
| |||||||||||||||||||||||||||||||||||||||||||||||
| 120 | $self->{app_names}{$app} = { | ||||||||||||||||||||||||||||||||||||||||||||||
| 121 | en => $A->{en}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 122 | fr => $A->{fr}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | if( $A->{package} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | $A = $A->{package}; | |||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | undef $r; | |||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 128 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | $A = $A->{code}; | |||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | $r = 'CODE'; | |||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | if( not $r and $controler->package_ctor( $A ) ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
not $r and $controler->package_ctor($A)
MC/DC0%0/2
not $r and $controler->package_ctor($A)
not $r
$controler->package_ctor($A)
Truth table0%0/3
not(A) and B
A= not $rB= $controler->package_ctor($A)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | $ok = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 136 | elsif( $r eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | $ok = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | unless( $ok ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | croak "apps parameter $app must be a code reference or name of a package that defines ->spawn, not $r ($A)"; | |||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | $self->{apps}{$app} = $A; | |||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||
| 147 | ############################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 148 | sub build_controler | ||||||||||||||||||||||||||||||||||||||||||||||
| 149 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 6 | ▶ | my( $self, $timeout, $apps ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_controler: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 6 | $self->{controler} = POE::XUL::Controler->new( $timeout, $apps ); | |||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||
| 155 | ############################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 156 | sub build_http_server | ||||||||||||||||||||||||||||||||||||||||||||||
| 157 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | my( $self, $addr, $port ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_http_server: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | $self->{mimetypes} = MIME::Types->new(); | |||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | my $alias = $self->{alias}; | |||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||
| 163 | $self->{aliases} = POE::Component::Server::HTTP->new( | ||||||||||||||||||||||||||||||||||||||||||||||
| 164 | Port => $self->{port}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | MapOrder => 'bottom-first', | |||||||||||||||||||||||||||||||||||||||||||||
| 166 | # PreHandler => { '/' => _mk_handler( $self, 'pre_connection' ) }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 167 | PostHandler => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 168 | '/' => _mk_handler( $self, 'post_connection' ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 169 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 170 | ContentHandler => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 171 | '/xul' => _mk_call( $alias, 'xul' ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 172 | '/xul/file/' => _mk_call( $alias, 'xul_file' ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 173 | '/__poe_size' => _mk_call( $alias, 'poe_size' ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 174 | '/__poe_kernel' => _mk_call( $alias, 'poe_kernel' ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 175 | '/__poe_text ' => _mk_call( $alias, 'poe_text' ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 176 | '/' => _mk_call( $alias, 'static' ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 177 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 178 | ErrorHandler => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 179 | '/' => _mk_call( $alias, 'httpd_error' ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 180 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||
| 182 | Headers => { 'X-POE-XUL' => $VERSION }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 183 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||
| 186 | ## We build these closures outside of build_http_server, because otherwise | ||||||||||||||||||||||||||||||||||||||||||||||
| 187 | ## they would capture a reference to $self | ||||||||||||||||||||||||||||||||||||||||||||||
| 188 | sub _mk_handler | ||||||||||||||||||||||||||||||||||||||||||||||
| 189 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | my( $self, $call ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mk_handler: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | return [ sub { RC_OK } ] unless $self; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | return [ sub { $self->$call(@_) } ] | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||
| 195 | sub _mk_call | ||||||||||||||||||||||||||||||||||||||||||||||
| 196 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | my( $alias, $handler ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mk_call: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | return sub { return $poe_kernel->call( $alias, $handler, @_ ) }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||
| 202 | ############################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 203 | # Introspection used for load balancer | ||||||||||||||||||||||||||||||||||||||||||||||
| 204 | sub port | ||||||||||||||||||||||||||||||||||||||||||||||
| 205 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | my( $self ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
port: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | my $sid = $self->{aliases}{tcp}; | |||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | my $tcp = $poe_kernel->alias_resolve( $sid ); | |||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | die "$$: Server::TCP has disapeared! tcp=$sid" unless $tcp; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | my $wheel = $tcp->get_heap->{listener}; | |||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | die "Server::TCP no longer has the listener wheel in 'listener'" | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 213 | unless $wheel; | ||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | my $sockname = $wheel->getsockname; | |||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | my($peer_port, $peer_addr) = unpack_sockaddr_in( $sockname ); | |||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | return $peer_port; | |||||||||||||||||||||||||||||||||||||||||||||
| 217 | # use Data::Denter; | ||||||||||||||||||||||||||||||||||||||||||||||
| 218 | # die Denter $sockname; | ||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||
| 221 | sub alias | ||||||||||||||||||||||||||||||||||||||||||||||
| 222 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | my( $self ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
alias: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | return $self->{alias}; | |||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||
| 227 | ############################################################################ | ||||||||||||||||||||||||||||||||||||||||||||||
| 228 | # POE methods | ||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||
| 230 | ############################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 231 | sub _start | ||||||||||||||||||||||||||||||||||||||||||||||
| 232 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 2 | ▶ | my ($self, $kernel, $session) = @_[OBJECT, KERNEL, SESSION]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_start: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 2 | $kernel->alias_set( $self->{alias} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 236 | 2 | $kernel->sig( shutdown => 'shutdown' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 237 | 2 | $kernel->sig( HUP => 'sig_HUP' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 238 | 2 | $kernel->sig( DIE => 'sig_DIE' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||
| 240 | # TODO: listen host | ||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 2 | $self->build_http_server( '0.0.0.0', $self->{port} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 242 | 2 | $self->log_setup; | |||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||
| 245 | # NB : no longer used | ||||||||||||||||||||||||||||||||||||||||||||||
| 246 | sub _stop | ||||||||||||||||||||||||||||||||||||||||||||||
| 247 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | xwarn "XUL stop"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stop: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||
| 251 | ############################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 252 | # Sane shutdown | ||||||||||||||||||||||||||||||||||||||||||||||
| 253 | sub shutdown | ||||||||||||||||||||||||||||||||||||||||||||||
| 254 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 2 | ▶ | my( $self ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
shutdown: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 256 | # xwarn "$$ XUL shutdown"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 2 | $self->{shutdown} = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 258 | 2 | $poe_kernel->post( $self->{aliases}{httpd}, 'shutdown' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 259 | 2 | $poe_kernel->alias_remove( delete $self->{alias} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 260 | 2 | $poe_kernel->sig( 'HUP' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||
| 263 | ############################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 264 | # POE Exception handling | ||||||||||||||||||||||||||||||||||||||||||||||
| 265 | sub sig_DIE | ||||||||||||||||||||||||||||||||||||||||||||||
| 266 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | my( $self, $kernel, $sig, $ex ) = @_[ OBJECT, KERNEL, ARG0, ARG1 ]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sig_DIE: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | xwarn "============================\nERROR: $sig $ex\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | xwarn "Exception in $ex->{event}: $ex->{error_str}\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||
| 275 | ############################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 276 | sub session_timeout | ||||||||||||||||||||||||||||||||||||||||||||||
| 277 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | my ($self, $kernel, $SID) = @_[OBJECT, KERNEL, ARG0]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
session_timeout: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | my $controler = $self->{controler}; | |||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | DEBUG and | |||||||||||||||||||||||||||||||||||||||||||||
| 281 | xwarn "Session timeout for $SID"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | if( defined $SID and $controler->exists( $SID ) ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $SID and $controler->exists($SID)
MC/DC0%0/2
defined $SID and $controler->exists($SID)
defined $SID
$controler->exists($SID)
Truth table0%0/3
A and B
A= defined $SIDB= $controler->exists($SID)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | DEBUG and | |||||||||||||||||||||||||||||||||||||||||||||
| 284 | xdebug "Timeout SID=$SID"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | $kernel->call( $SID, 'timeout', $SID ); # TODO unit test | |||||||||||||||||||||||||||||||||||||||||||||
| 286 | # unregister will send the 'shutdown' event | ||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | $controler->unregister( $SID ); | |||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||
| 291 | ############################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 292 | # Get the number of active sessions. | ||||||||||||||||||||||||||||||||||||||||||||||
| 293 | # Used by IGDAIP::App to see when a backend should exit | ||||||||||||||||||||||||||||||||||||||||||||||
| 294 | sub session_count | ||||||||||||||||||||||||||||||||||||||||||||||
| 295 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | my ($self, $kernel) = @_[ OBJECT, KERNEL ]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
session_count: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | return $self->{controler}->count; | |||||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||
| 300 | ############################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 301 | # Verify if a session exists | ||||||||||||||||||||||||||||||||||||||||||||||
| 302 | sub session_exists | ||||||||||||||||||||||||||||||||||||||||||||||
| 303 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | my ($self, $kernel, $SID ) = @_[ OBJECT, KERNEL, ARG0 ]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
session_exists: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | return $self->{controler}->exists( $SID ); | |||||||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||
| 312 | ############################################################################ | ||||||||||||||||||||||||||||||||||||||||||||||
| 313 | # XUL request handling | ||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||
| 315 | ############################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 316 | # Get the arguments out of a request | ||||||||||||||||||||||||||||||||||||||||||||||
| 317 | sub parse_args | ||||||||||||||||||||||||||||||||||||||||||||||
| 318 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | my( $self, $req ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_args: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | return POE::XUL::Request->new( $req ); | |||||||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||
| 324 | ############################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 325 | # Report an error in the request parsing | ||||||||||||||||||||||||||||||||||||||||||||||
| 326 | sub parse_error | ||||||||||||||||||||||||||||||||||||||||||||||
| 327 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | ▶ | my( $self, $rc ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_error: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | $self->error_standard( $rc, "argument parsing" ); | |||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||
| 333 | ############################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 334 | # A request under /xul for an application | ||||||||||||||||||||||||||||||||||||||||||||||
| 335 | sub xul | ||||||||||||||||||||||||||||||||||||||||||||||
| 336 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | my( $self, $kernel, $req, $resp ) = @_[ OBJECT, KERNEL, ARG0..$#_ ]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xul: not called CC=17 SCAR=57.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | DEBUG and | |||||||||||||||||||||||||||||||||||||||||||||
| 340 | warn "$$: xul"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | if( $self->{shutdown} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | xwarn "XUL request, but we are shutdown\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | local $self->{request} = $req; | |||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | local $self->{response} = $resp; | |||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | DEBUG and xwarn "XUL request"; | |||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | my $controler = $self->{controler}; | |||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | my $uri = $req->uri->path; | |||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | ▶ | if( $uri ne '/xul' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | return $self->error_standard( RC_BAD_REQUEST, "parsing uri", | |||||||||||||||||||||||||||||||||||||||||||||
| 356 | "$uri isn't a valid path\n" ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | my $ret = $self->parse_args( $req ); | |||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | unless( ref $ret ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | return $self->parse_error( $ret ); | |||||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | $req->{start} = time; | |||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | my $SID = $req->param( 'SID' ) || ''; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$req->param('SID') || ''
MC/DC0%0/1
$req->param('SID') || ''
$req->param('SID')
Truth table0%0/2
A
A= $req->param('SID')
| |||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | ▶ | my $event = $req->param( 'event' ) || 'boot'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$req->param('event') || 'boot'
MC/DC0%0/1
$req->param('event') || 'boot'
$req->param('event')
Truth table0%0/2
A
A= $req->param('event')
| |||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | my $app = $req->param( 'app' ) || ''; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$req->param('app') || ''
MC/DC0%0/1
$req->param('app') || ''
$req->param('app')
Truth table0%0/2
A
A= $req->param('app')
| |||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | DEBUG and xdebug "Request for app=$app SID=$SID event=$event"; | |||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | unless( $app and $event ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$app and $event
MC/DC0%0/2
$app and $event
$app
$event
Truth table0%0/3
A and B
A= $appB= $event
| |||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | $req->pre_log; | |||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | xlog "app=$app SID=$SID event=$event is an empty request"; | |||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | return $self->error( RC_BAD_REQUEST, 'Empty request' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | my $rc; | |||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | local $self->{logging}->{app} = $app; | |||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | $req->pre_log; | |||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | if( $event eq 'boot' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | my $fail = $controler->boot( $req, $resp ); | |||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | if( $fail ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 384 | # boot failed | ||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | $rc = $self->error_boot_fail( $fail ); | |||||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 388 | ## TODO: move the rest of this into Controler->something | ||||||||||||||||||||||||||||||||||||||||||||||
| 389 | elsif( ! $controler->exists( $SID ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | $rc = $self->error_unknown_session( $SID ); | |||||||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 392 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | $controler->keepalive( $SID ); | |||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | if( $event eq 'connect' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | $controler->connect( $SID, $req, $resp ); | |||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 397 | elsif( $event eq 'disconnect' ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | $controler->disconnect( $SID, $req, $resp ); | |||||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 400 | elsif( $event eq 'close' ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | $controler->close( $SID, $req, $resp ); | |||||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 403 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 404 | # everything else is a DOM event | ||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | $controler->request( $SID, $event, $req, $resp ); | |||||||||||||||||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | ▶ | $rc ||= RC_WAIT; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$rc ||= -1
MC/DC0%0/1
$rc ||= -1
$rc
Truth table0%0/2
A
A= $rc
| |||||||||||||||||||||||||||||||||||||||||||||||
| 409 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | ▶ | unless( defined $rc ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | warn "Error: $@"; | |||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | $rc = $self->error_standard( RC_INTERNAL_SERVER_ERROR, $event, $@ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | return $rc; | |||||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||
| 419 | ############################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 420 | ## Request for a file that starts with /xul/ | ||||||||||||||||||||||||||||||||||||||||||||||
| 421 | sub xul_file | ||||||||||||||||||||||||||||||||||||||||||||||
| 422 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | ▶ | my( $self, $kernel, $req, $resp ) = @_[ OBJECT, KERNEL, ARG0..$#_ ]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xul_file: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||
| 425 | # DEBUG and | ||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | warn "$$: xul_file"; | |||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | my $uri = $req->uri->path; | |||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | ▶ | unless( $uri =~ m(^/xul/file(/(.*))?) ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | return $self->error_standard( RC_BAD_REQUEST, "parsing uri", | |||||||||||||||||||||||||||||||||||||||||||||
| 430 | "$uri isn't a valid path\n" ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | my $filename = $2||''; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$2 || ''
MC/DC0%0/1
$2 || ''
$2
Truth table0%0/2
A
A= $2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | $req->uri->path( '/xul' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | my $ret = $self->parse_args( $req ); | |||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | unless( ref $ret ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | return $self->parse_error( $ret ); | |||||||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | $req->param( filename => $filename ); | |||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | return shift->xul( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||||||
| 445 | ############################################################################ | ||||||||||||||||||||||||||||||||||||||||||||||
| 446 | # Static file handling | ||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||
| 448 | ############################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 449 | sub static | ||||||||||||||||||||||||||||||||||||||||||||||
| 450 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | ▶ | my( $self, $kernel, $req, $resp ) = @_[ OBJECT, KERNEL, ARG0..$#_ ]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
static: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | DEBUG and | |||||||||||||||||||||||||||||||||||||||||||||
| 454 | xwarn "POE::Component::XUL->static"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | ▶ | if( $self->{shutdown} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | xwarn "Static request, but we are shutdown\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | local $self->{request} = $req; | |||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | local $self->{response} = $resp; | |||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | my $ret; | |||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | my $method = $req->method; | |||||||||||||||||||||||||||||||||||||||||||||
| 466 | # Verify HTTP method | ||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | ▶ | unless( $method eq 'GET' or $method eq 'HEAD' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$method eq "GET" or $method eq "HEAD"
MC/DC0%0/2
$method eq "GET" or $method eq "HEAD"
$method eq "GET"
$method eq "HEAD"
Truth table0%0/3
A or B
A= $method eq "GET"B= $method eq "HEAD"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | $ret = $self->error_standard( RC_METHOD_NOT_ALLOWED, $method ); | |||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||
| 472 | # Send the file | ||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | my $uri = $req->uri->path; | |||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | DEBUG and | |||||||||||||||||||||||||||||||||||||||||||||
| 475 | xdebug "Static request: $uri"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | my $file = $self->uri_to_file( $uri ); | |||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | if( -d $file ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | $ret = $self->static_file( $uri, 'index.html' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 481 | elsif( -f "$file.build" ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | $ret = $self->build_file( $uri, $file ); | |||||||||||||||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 484 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | $ret = $self->static_file( $uri ); | |||||||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | DEBUG and xwarn "$$: ret=$ret"; | |||||||||||||||||||||||||||||||||||||||||||||
| 488 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | ▶ | if( $ret ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | $resp->code( $ret ); | |||||||||||||||||||||||||||||||||||||||||||||
| 492 | # $response->continue; | ||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | return $ret; | |||||||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | $self->error_standard( RC_INTERNAL_SERVER_ERROR, "serving static file", $@ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||||||
| 498 | #################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 499 | sub uri_to_file | ||||||||||||||||||||||||||||||||||||||||||||||
| 500 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | ▶ | my( $self, @path ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uri_to_file: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | my $path = File::Spec->catfile( grep {defined} @path ); | |||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | $path =~ s(/\./)(/)g; | |||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | $path =~ s(/\.\./)(/)g; | |||||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | unless( $path =~ s(^/)($self->{static_root}/) ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | $path = File::Spec->catfile( $self->{static_root}, $path ); | |||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | $path =~ s(//)(/)g; | |||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | return $path; | |||||||||||||||||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||||||
| 514 | #################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 515 | sub static_file | ||||||||||||||||||||||||||||||||||||||||||||||
| 516 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 1 | ▶ | my( $self, $uri, $file ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
static_file: called CC=15 SCAR=37.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 1 | my $req = $self->{request}; | |||||||||||||||||||||||||||||||||||||||||||||
| 520 | 1 | my $resp = $self->{response}; | |||||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 1 | my $fullfile = $file; | |||||||||||||||||||||||||||||||||||||||||||||
| 523 | 1 | ▶ | if( $uri ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | $fullfile = $self->uri_to_file( $uri, $file ); | |||||||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 1 | DEBUG and xdebug "Static file: $fullfile"; | |||||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||||||
| 529 | # warn "REQUEST=", $req->as_string; | ||||||||||||||||||||||||||||||||||||||||||||||
| 530 | # Does the file exist? | ||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 1 | ▶ | return $self->error_not_found( $fullfile ) unless -f $fullfile; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 1 | my $lastmod = (stat _)[9]; | |||||||||||||||||||||||||||||||||||||||||||||
| 534 | 1 | my $size = (stat _)[7]; | |||||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||||||
| 536 | # open the file | ||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 1 | my $in = IO::File->new( $fullfile ); | |||||||||||||||||||||||||||||||||||||||||||||
| 538 | 1 | ▶ | unless( $in ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | return $self->error( RC_FORBIDDEN, "$uri: $!" ); | |||||||||||||||||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||||||
| 542 | # Make sure it's not too huge | ||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 1 | ▶ | if( $size > 1024 * 1024 ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | return $self->error_standard( RC_REQUEST_ENTITY_TOO_LARGE, | |||||||||||||||||||||||||||||||||||||||||||||
| 545 | "looking at the file", | ||||||||||||||||||||||||||||||||||||||||||||||
| 546 | "$size is much to large" ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||||||
| 549 | # set up content-type | ||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 1 | my $ct = $self->guess_ct( $fullfile ); | |||||||||||||||||||||||||||||||||||||||||||||
| 551 | 1 | DEBUG and xdebug "content_type=$ct\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 552 | 1 | $self->{response}->content_type( $ct ); | |||||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||||||
| 554 | # add useful headers | ||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 1 | ▶ | if( $lastmod and not $ct =~ m(^application/vnd\.mozilla\.xul\+xml$) ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$lastmod and not $ct =~ m[^application/vnd\.mozilla\.xul\+xml$]
MC/DC0%0/2
$lastmod and not $ct =~ m[^application/vnd\.mozilla\.xul\+xml$]
$lastmod
not $ct =~ m[^application/vnd\.mozilla\.xul\+xml$]
Truth table33%1/3
A and not(B)
A= $lastmodB= not $ct =~ m[^application/vnd\.mozilla\.xul\+xml$]
| |||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 1 | DEBUG and xdebug "Last-modified=", time2str( $lastmod ); | |||||||||||||||||||||||||||||||||||||||||||||
| 557 | 1 | $self->{response}->header( 'Last-Modified' => | |||||||||||||||||||||||||||||||||||||||||||||
| 558 | time2str( $lastmod ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 559 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||||||
| 562 | # bail if HEAD request | ||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 1 | ▶ | if ( $req->method eq 'HEAD' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | DEBUG and | |||||||||||||||||||||||||||||||||||||||||||||
| 565 | xdebug "HEAD size=$size"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | $resp->content_length( $size ); | |||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | return RC_OK; | |||||||||||||||||||||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||||||
| 570 | # RFC1945 says HEAD should ingore if-modified-since | ||||||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||||||
| 572 | # 304 check | ||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 1 | my $since = $req->header( 'If-Modified-Since' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 574 | 1 | ▶ | if( $since ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | DEBUG and xdebug "If-mod-since=$since"; | |||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | $since = str2time( $since ); | |||||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | ▶ | if ( $lastmod && $since && $since >= $lastmod ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$lastmod and $since and $since >= $lastmod
$lastmod and $since
MC/DC0%0/3
$lastmod and $since and $since >= $lastmod
$lastmod
$since
$since >= $lastmod
Truth table0%0/4
A and B and C
A= $lastmodB= $sinceC= $since >= $lastmod
| |||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | DEBUG and xdebug "NOT MODIFIED SINCE (size=$size)"; | |||||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | $resp->header( 'Last-Modified' => '' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | return RC_NOT_MODIFIED; | |||||||||||||||||||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 584 | # warn "RESPONSE=", $self->{response}->as_string; | ||||||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||||||
| 586 | # Read and set the content | ||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 1 | my $c = join '', <$in>; | |||||||||||||||||||||||||||||||||||||||||||||
| 588 | 1 | undef( $in ); | |||||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 1 | ▶ | if( ($uri eq '/' or $uri =~ m(^/index.html?)) and | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$uri eq "/" || $uri =~ m[^/index.html?] and $c =~ /\[APP-LIST\]/
$uri eq "/" or $uri =~ m[^/index.html?]
MC/DC0%0/3
$uri eq "/" || $uri =~ m[^/index.html?] and $c =~ /\[APP-LIST\]/
$uri eq "/"
$uri =~ m[^/index.html?]
$c =~ /\[APP-LIST\]/
Truth table20%1/5
A or B and C
A= $uri eq "/"B= $uri =~ m[^/index.html?]C= $c =~ /\[APP-LIST\]/
| |||||||||||||||||||||||||||||||||||||||||||||||
| 591 | $c =~ /\[APP-LIST\]/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | my $alist = $self->app_list; | |||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | $c =~ s/\[APP-LIST\]/$alist/g; | |||||||||||||||||||||||||||||||||||||||||||||
| 594 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 1 | $self->{response}->content( $c ); | |||||||||||||||||||||||||||||||||||||||||||||
| 597 | 1 | $self->{response}->content_length( length $c ); | |||||||||||||||||||||||||||||||||||||||||||||
| 598 | 1 | return RC_OK; | |||||||||||||||||||||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||||||
| 601 | #################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 602 | sub app_list | ||||||||||||||||||||||||||||||||||||||||||||||
| 603 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | ▶ | my( $self ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
app_list: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | my @html = <<HTML; | |||||||||||||||||||||||||||||||||||||||||||||
| 606 | <script type="text/javascript"><!-- | ||||||||||||||||||||||||||||||||||||||||||||||
| 607 | function Link(name) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 608 | window.open( | ||||||||||||||||||||||||||||||||||||||||||||||
| 609 | "start.xul?" + name + "#1" , | ||||||||||||||||||||||||||||||||||||||||||||||
| 610 | (new Date()).getTime(), | ||||||||||||||||||||||||||||||||||||||||||||||
| 611 | "toolbar=0,menubar=0,status=0,resizable=1" | ||||||||||||||||||||||||||||||||||||||||||||||
| 612 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 613 | return false; | ||||||||||||||||||||||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 615 | // -> | ||||||||||||||||||||||||||||||||||||||||||||||
| 616 | </script> | ||||||||||||||||||||||||||||||||||||||||||||||
| 617 | <ul id="POE-XUL-application-list"> | ||||||||||||||||||||||||||||||||||||||||||||||
| 618 | HTML | ||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | my $lang = $self->language_guess; | |||||||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | ▶ | my $text = $lang eq 'fr' ? "Avec menus" : "Keep menus"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | my $count = keys %{ $self->{apps} }; | |||||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | foreach my $app ( sort keys %{ $self->{apps} } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | ▶ | next if $app eq 'IGDAIP' and 1 != $count; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$app eq "IGDAIP" and 1 != $count
MC/DC0%0/2
$app eq "IGDAIP" and 1 != $count
$app eq "IGDAIP"
1 != $count
Truth table0%0/3
A and B
A= $app eq "IGDAIP"B= 1 != $count
| |||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | ▶ | my $name = $self->{app_names}{$app}{$lang} || $app; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{'app_names'}{$app}{$lang} || $app
MC/DC0%0/2
$self->{'app_names'}{$app}{$lang} || $app
$self->{'app_names'}{$app}{$lang}
$app
Truth table0%0/3
A || B
A= $self->{'app_names'}{$app}{$lang}B= $app
| |||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | push @html, <<HTML; | |||||||||||||||||||||||||||||||||||||||||||||
| 627 | <li><a href="start.xul?$app" onclick="return Link('$app')">$name</a> | ||||||||||||||||||||||||||||||||||||||||||||||
| 628 | (<a href="start.xul?$app">$text</a>)</li> | ||||||||||||||||||||||||||||||||||||||||||||||
| 629 | HTML | ||||||||||||||||||||||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | push @html, "</ul>"; | |||||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | return join "\n", @html; | |||||||||||||||||||||||||||||||||||||||||||||
| 634 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||||||
| 636 | sub language_guess | ||||||||||||||||||||||||||||||||||||||||||||||
| 637 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | ▶ | my( $self ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
language_guess: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | ▶ | return $self->{default_language} unless $self->{request}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | my $accept = $self->{request}->header( 'Accept-Language' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 641 | $self->{acceptor} ||= I18N::AcceptLanguage->new( | ||||||||||||||||||||||||||||||||||||||||||||||
| 642 | defaultLanguage => $self->{default_language}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | ▶ | strict => 0 | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"acceptor"} ||= "I18N::AcceptLanguage"->new("defaultLanguage", $self->{"default_language"}, "strict", 0)
MC/DC0%0/2
$self->{"acceptor"} ||= "I18N::AcceptLanguage"->new("defaultLanguage", $self->{"default_language"}, "strict", 0)
$self->{"acceptor"}
"I18N::AcceptLanguage"->new("defaultLanguage", $self->{"default_language"}, "strict", 0)
Truth table0%0/3
A ||= B
A= $self->{"acceptor"}B= "I18N::AcceptLanguage"->new("defaultLanguage", $self->{"default_language"}, "strict", 0)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 644 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | return $self->{acceptor}->accepts( $accept, $self->{languages} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 646 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||||||
| 648 | #################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 649 | # Build a file out of smaller files | ||||||||||||||||||||||||||||||||||||||||||||||
| 650 | # This removes the need for complex Makefiles to build up a single | ||||||||||||||||||||||||||||||||||||||||||||||
| 651 | # javascript / CSS / XBL file. | ||||||||||||||||||||||||||||||||||||||||||||||
| 652 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 653 | # The Build files is the filename + .build extention | ||||||||||||||||||||||||||||||||||||||||||||||
| 654 | # A Cache file is the filename + .cache extention | ||||||||||||||||||||||||||||||||||||||||||||||
| 655 | sub build_file | ||||||||||||||||||||||||||||||||||||||||||||||
| 656 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 1 | ▶ | my( $self, $uri, $fullfile ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_file: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 1 | my $bfile = "$fullfile.build"; | |||||||||||||||||||||||||||||||||||||||||||||
| 660 | 1 | my $bage = (stat $bfile)[9]; | |||||||||||||||||||||||||||||||||||||||||||||
| 661 | 1 | my $cfile = "$fullfile.cache"; | |||||||||||||||||||||||||||||||||||||||||||||
| 662 | 1 | my $cage = (stat $cfile)[9]; | |||||||||||||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 1 | ▶ | unless( $cage and $cage > $bage ) { # cache file isn't newer then build file | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$cage and $cage > $bage
MC/DC0%0/2
$cage and $cage > $bage
$cage
$cage > $bage
Truth table33%1/3
A and B
A= $cageB= $cage > $bage
| |||||||||||||||||||||||||||||||||||||||||||||||
| 665 | # so we have to create the cache file | ||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 1 | local $self->{loop_check} = {}; | |||||||||||||||||||||||||||||||||||||||||||||
| 667 | 1 | $self->create_cache_file( $cfile, $bfile ); | |||||||||||||||||||||||||||||||||||||||||||||
| 668 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 1 | return $self->static_file( '', $cfile ); | |||||||||||||||||||||||||||||||||||||||||||||
| 671 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||||||
| 673 | ############################################################ | ||||||||||||||||||||||||||||||||||||||||||||||
| 674 | # Recursively create the file in $cfile from $bfile | ||||||||||||||||||||||||||||||||||||||||||||||
| 675 | sub create_cache_file | ||||||||||||||||||||||||||||||||||||||||||||||
| 676 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 8 | ▶ | my( $self, $cfile, $bfile ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_cache_file: called CC=6 SCAR=18.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 8 | my $out = $cfile; | |||||||||||||||||||||||||||||||||||||||||||||
| 679 | 8 | ▶ | $out = IO::File->new( "> $cfile" ) unless ref $cfile; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 8 | my $dir = dirname $bfile; | |||||||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 8 | ▶ | if( $self->{loop_check}{ $bfile } ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | die "Recursion detected: $bfile included more then once"; | |||||||||||||||||||||||||||||||||||||||||||||
| 685 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 8 | local $self->{loop_check}{ $bfile } = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 8 | ▶ | my $in = IO::File->new( $bfile ) or die "Unable to read $bfile: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 8 | ▶ | while( my $line = <$in> ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 16 | ▶ | if( $line =~ /^\s*\@include "(.+)"\s*$/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 6 | my $file = File::Spec->rel2abs( $1, $dir ); | |||||||||||||||||||||||||||||||||||||||||||||
| 692 | 6 | $self->create_cache_file( $out, $file ); | |||||||||||||||||||||||||||||||||||||||||||||
| 693 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 694 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 10 | $out->print( $line ); | |||||||||||||||||||||||||||||||||||||||||||||
| 696 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 697 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 698 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||||||||||||||||
| 700 | ############################################################ | ||||||||||||||||||||||||||||||||||||||||||||||
| 701 | sub guess_ct | ||||||||||||||||||||||||||||||||||||||||||||||
| 702 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 3 | ▶ | my($self, $file)=@_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
guess_ct: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 3 | $file =~ s/\.cache$//; | |||||||||||||||||||||||||||||||||||||||||||||
| 705 | 3 | my $ct = $self->{mimetypes}->mimeTypeOf( $file ); | |||||||||||||||||||||||||||||||||||||||||||||
| 706 | 3 | ▶ | $ct ||= 'application/octet-stream'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$ct ||= "application/octet-stream"
MC/DC100%1/1
$ct ||= "application/octet-stream"
$ct
Truth table100%2/2
A
A= $ct
| |||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 3 | ▶ | $ct .= '; charset=iso-8859-1' if $ct eq 'text/html'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 3 | return $ct; | |||||||||||||||||||||||||||||||||||||||||||||
| 710 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||||||||||||||||||||
| 712 | ############################################################ | ||||||||||||||||||||||||||||||||||||||||||||||
| 713 | # URI that would restart an application | ||||||||||||||||||||||||||||||||||||||||||||||
| 714 | sub uri_restart | ||||||||||||||||||||||||||||||||||||||||||||||
| 715 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | ▶ | my( $self ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uri_restart: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 0 | my $req = $self->{request}; | |||||||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | my $uri = $req->uri; | |||||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||||||
| 720 | # We need to know what the browser thinks we are called | ||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | my $host = $req->header( 'X-Forwarded-Host' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | ▶ | if( $host ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | xwarn "Restart on $host"; | |||||||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | $host =~ s/,.+$//; | |||||||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | $uri->host( $host ); | |||||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | ▶ | $uri->port( undef ) if defined $uri->port and 0==$uri->port; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $uri->port and 0 == $uri->port
MC/DC0%0/2
defined $uri->port and 0 == $uri->port
defined $uri->port
0 == $uri->port
Truth table0%0/3
A and B
A= defined $uri->portB= 0 == $uri->port
| |||||||||||||||||||||||||||||||||||||||||||||||
| 727 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | my $referer = $req->header( 'Referer' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | ▶ | if( $referer and $referer =~ /https/ ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$referer and $referer =~ /https/
MC/DC0%0/2
$referer and $referer =~ /https/
$referer
$referer =~ /https/
Truth table0%0/3
A and B
A= $refererB= $referer =~ /https/
| |||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 0 | $uri->scheme( 'https' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 731 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | $uri->path( '/start.xul' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | my $app = $req->param( 'app' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | $uri->query_keywords( $app ); | |||||||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | return $uri; | |||||||||||||||||||||||||||||||||||||||||||||
| 736 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||||||
| 738 | ############################################################################ | ||||||||||||||||||||||||||||||||||||||||||||||
| 739 | # Error handling | ||||||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||||||
| 741 | ############################################################ | ||||||||||||||||||||||||||||||||||||||||||||||
| 742 | sub error | ||||||||||||||||||||||||||||||||||||||||||||||
| 743 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | ▶ | my($self, $code, $text, $ct)=@_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | ▶ | $ct ||= 'text/plain'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$ct ||= "text/plain"
MC/DC0%0/1
$ct ||= "text/plain"
$ct
Truth table0%0/2
A
A= $ct
| |||||||||||||||||||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||||||||||||||||
| 748 | # This could get annoying fast. It also shows 404s | ||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 0 | ▶ | warn "$code $text\n"unless $ENV{AUTOMATED_TESTING}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 0 | ▶ | xlog "$code $text\n" | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ct eq "text/plain" and $code != 404
MC/DC0%0/2
$ct eq "text/plain" and $code != 404
$ct eq "text/plain"
$code != 404
Truth table0%0/3
A and B
A= $ct eq "text/plain"B= $code != 404
| |||||||||||||||||||||||||||||||||||||||||||||||
| 751 | if $ct eq 'text/plain' and (DEBUG or $code != RC_NOT_FOUND); | ||||||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | ▶ | if( $self->{response} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | $self->{response}->code( $code ); | |||||||||||||||||||||||||||||||||||||||||||||
| 755 | 0 | $self->{response}->content_type( $ct ); | |||||||||||||||||||||||||||||||||||||||||||||
| 756 | 0 | ▶ | if( $ct eq 'text/html' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | $text = encode_entities_numeric( $text, "\x80-\xff" ); | |||||||||||||||||||||||||||||||||||||||||||||
| 758 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | $self->{response}->content( $text ); | |||||||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | $self->{response}->content_length( length $text ); | |||||||||||||||||||||||||||||||||||||||||||||
| 762 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 763 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 0 | xcarp "Response was already sent!"; | |||||||||||||||||||||||||||||||||||||||||||||
| 765 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 0 | return $code; | |||||||||||||||||||||||||||||||||||||||||||||
| 767 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||||||||||||||||||||
| 769 | ############################################################ | ||||||||||||||||||||||||||||||||||||||||||||||
| 770 | sub error_standard | ||||||||||||||||||||||||||||||||||||||||||||||
| 771 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 0 | ▶ | my( $self, $code, $when, $what ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error_standard: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||||||||||||||
| 774 | # Thank you HTTP::Status | ||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 0 | my $message = status_message( $code ); | |||||||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | ▶ | $message ||= 'unknown'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$message ||= "unknown"
MC/DC0%0/1
$message ||= "unknown"
$message
Truth table0%0/2
A
A= $message
| |||||||||||||||||||||||||||||||||||||||||||||||
| 777 | |||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 0 | ▶ | $what ||= ''; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$what ||= ""
MC/DC0%0/1
$what ||= ""
$what
Truth table0%0/2
A
A= $what
| |||||||||||||||||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | return $self->error( $code, "Error while $when: $message ($code)\n$what" ); | |||||||||||||||||||||||||||||||||||||||||||||
| 781 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||||||||||||||||||||
| 783 | ############################################################ | ||||||||||||||||||||||||||||||||||||||||||||||
| 784 | sub error_not_found | ||||||||||||||||||||||||||||||||||||||||||||||
| 785 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 0 | ▶ | my( $self, $file ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error_not_found: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 0 | my $msg = "Unknown file '$file'"; | |||||||||||||||||||||||||||||||||||||||||||||
| 788 | 0 | xwarn "$msg\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 0 | return $self->error( RC_NOT_FOUND, <<" HTML", 'text/html'); | |||||||||||||||||||||||||||||||||||||||||||||
| 791 | <html> | ||||||||||||||||||||||||||||||||||||||||||||||
| 792 | <head><title>404 N'existe pas</title></head> | ||||||||||||||||||||||||||||||||||||||||||||||
| 793 | <body> | ||||||||||||||||||||||||||||||||||||||||||||||
| 794 | <h1>Le fichier que vous cherchez ne semble pas exister.</h1> | ||||||||||||||||||||||||||||||||||||||||||||||
| 795 | <pre>$msg</pre> | ||||||||||||||||||||||||||||||||||||||||||||||
| 796 | </body> | ||||||||||||||||||||||||||||||||||||||||||||||
| 797 | </html> | ||||||||||||||||||||||||||||||||||||||||||||||
| 798 | HTML | ||||||||||||||||||||||||||||||||||||||||||||||
| 799 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||||||
| 801 | ############################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 802 | ## TODO : as XUL | ||||||||||||||||||||||||||||||||||||||||||||||
| 803 | sub error_unknown_session | ||||||||||||||||||||||||||||||||||||||||||||||
| 804 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | ▶ | my( $self, $SID ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error_unknown_session: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 0 | xwarn "Unknown session $SID"; | |||||||||||||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 0 | my $url = $self->uri_restart; | |||||||||||||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | return $self->error( RC_GONE, <<" HTML", 'text/html'); | |||||||||||||||||||||||||||||||||||||||||||||
| 812 | <html> | ||||||||||||||||||||||||||||||||||||||||||||||
| 813 | <head><title>410 absent</title></head> | ||||||||||||||||||||||||||||||||||||||||||||||
| 814 | <body> | ||||||||||||||||||||||||||||||||||||||||||||||
| 815 | <h1>Program inexistante</h1> | ||||||||||||||||||||||||||||||||||||||||||||||
| 816 | <p>Votre session (<tt>$SID</tt>) n'existe pas. Elle est surement expirée.</p> | ||||||||||||||||||||||||||||||||||||||||||||||
| 817 | <p><a href="$url">Ouvrir une nouvelle session</a>.</p> | ||||||||||||||||||||||||||||||||||||||||||||||
| 818 | </body> | ||||||||||||||||||||||||||||||||||||||||||||||
| 819 | </html> | ||||||||||||||||||||||||||||||||||||||||||||||
| 820 | HTML | ||||||||||||||||||||||||||||||||||||||||||||||
| 821 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||||||||
| 823 | ############################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 824 | ## TODO : as XUL | ||||||||||||||||||||||||||||||||||||||||||||||
| 825 | sub error_boot_fail | ||||||||||||||||||||||||||||||||||||||||||||||
| 826 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 0 | ▶ | my( $self, $fail ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error_boot_fail: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 828 | |||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 0 | return $self->error( RC_NOT_FOUND, <<" HTML", 'text/html'); | |||||||||||||||||||||||||||||||||||||||||||||
| 830 | <html> | ||||||||||||||||||||||||||||||||||||||||||||||
| 831 | <head><title>404 absent</title></head> | ||||||||||||||||||||||||||||||||||||||||||||||
| 832 | <body> | ||||||||||||||||||||||||||||||||||||||||||||||
| 833 | <h1>Écheque au démarrage</h1> | ||||||||||||||||||||||||||||||||||||||||||||||
| 834 | <p>$fail</p> | ||||||||||||||||||||||||||||||||||||||||||||||
| 835 | </body> | ||||||||||||||||||||||||||||||||||||||||||||||
| 836 | </html> | ||||||||||||||||||||||||||||||||||||||||||||||
| 837 | HTML | ||||||||||||||||||||||||||||||||||||||||||||||
| 838 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||||||||||||||||||||
| 840 | |||||||||||||||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||||||||||||||
| 842 | |||||||||||||||||||||||||||||||||||||||||||||||
| 843 | ############################################################ | ||||||||||||||||||||||||||||||||||||||||||||||
| 844 | sub httpd_error | ||||||||||||||||||||||||||||||||||||||||||||||
| 845 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | ▶ | my( $self, $request, $response) = @_[ OBJECT, ARG0..$#_ ]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
httpd_error: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 0 | my $op=$request->header('Operation'); | |||||||||||||||||||||||||||||||||||||||||||||
| 849 | 0 | my $errnum=$request->header('Errnum'); | |||||||||||||||||||||||||||||||||||||||||||||
| 850 | 0 | my $errstr=$request->header('Error'); | |||||||||||||||||||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 0 | DEBUG and | |||||||||||||||||||||||||||||||||||||||||||||
| 853 | xdebug "HTTPD ERROR op=$op errstr=$errstr errnum=$errnum\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 854 | |||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 0 | ▶ | if($op eq 'read' and ($errnum==0 or $errnum = ECONNRESET)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$op eq "read" and $errnum == 0 || ($errnum = 104)
$errnum == 0 or $errnum = 104
MC/DC0%0/2
$op eq "read" and $errnum == 0 || ($errnum = 104)
$op eq "read"
$errnum == 0
Truth table0%0/3
A and B
A= $op eq "read"B= $errnum == 0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 856 | # remote closed | ||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 0 | ▶ | if( $self->{controler} and $request ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"controler"} and $request
MC/DC0%0/2
$self->{"controler"} and $request
$self->{"controler"}
$request
Truth table0%0/3
A and B
A= $self->{"controler"}B= $request
| |||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | DEBUG and | |||||||||||||||||||||||||||||||||||||||||||||
| 859 | xdebug "$$ REMOTE CLOSED req=$request"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 0 | $self->{controler}->cancel( $request ); | |||||||||||||||||||||||||||||||||||||||||||||
| 861 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 862 | # PostHandler will deal with resuming the listening socket | ||||||||||||||||||||||||||||||||||||||||||||||
| 863 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 864 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | xwarn "Error during $op: [$errnum] $errstr"; | |||||||||||||||||||||||||||||||||||||||||||||
| 866 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 0 | return RC_OK; | |||||||||||||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||||||||||||||
| 870 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||||||||||||||||
| 872 | ############################################################################ | ||||||||||||||||||||||||||||||||||||||||||||||
| 873 | # Peeking | ||||||||||||||||||||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||||||||||||||||||||
| 875 | ############################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 876 | sub poe_size | ||||||||||||||||||||||||||||||||||||||||||||||
| 877 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 0 | ▶ | my( $self, $kernel, $req, $resp ) = @_[ OBJECT, KERNEL, ARG0, ARG1 ]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
poe_size: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | my $content = -1; | |||||||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | if( DEBUG and $HAVE_DEVEL_SIZE ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 882 | $content = Devel::Size::total_size( $kernel ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 883 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | $resp->code( RC_OK ); | |||||||||||||||||||||||||||||||||||||||||||||
| 885 | 0 | $resp->content_type( 'text/plain' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 886 | 0 | $resp->content_length( length $content ); | |||||||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | $resp->content( $content ); | |||||||||||||||||||||||||||||||||||||||||||||
| 888 | 0 | return RC_OK; | |||||||||||||||||||||||||||||||||||||||||||||
| 889 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 890 | |||||||||||||||||||||||||||||||||||||||||||||||
| 891 | sub poe_kernel | ||||||||||||||||||||||||||||||||||||||||||||||
| 892 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 0 | ▶ | my( $self, $kernel, $req, $resp ) = @_[ OBJECT, KERNEL, ARG0, ARG1 ]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
poe_kernel: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 0 | my $content = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 896 | 0 | if( DEBUG and $HAVE_DATA_DUMPER ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 897 | local $Data::Dumper::Indent = 1; | ||||||||||||||||||||||||||||||||||||||||||||||
| 898 | $content = Data::Dumper::Dumper( $kernel ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 899 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | $resp->code( RC_OK ); | |||||||||||||||||||||||||||||||||||||||||||||
| 901 | 0 | $resp->content_type( 'text/plain' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 902 | 0 | $resp->content_length( length $content ); | |||||||||||||||||||||||||||||||||||||||||||||
| 903 | 0 | $resp->content( $content ); | |||||||||||||||||||||||||||||||||||||||||||||
| 904 | 0 | return RC_OK; | |||||||||||||||||||||||||||||||||||||||||||||
| 905 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||||||||||||||||||||
| 907 | sub poe_test | ||||||||||||||||||||||||||||||||||||||||||||||
| 908 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 0 | ▶ | my( $self, $kernel, $req, $resp ) = @_[ OBJECT, KERNEL, ARG0, ARG1 ]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
poe_test: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 910 | |||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 0 | local $self->{request} = $req; | |||||||||||||||||||||||||||||||||||||||||||||
| 912 | 0 | local $self->{response} = $resp; | |||||||||||||||||||||||||||||||||||||||||||||
| 913 | |||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 0 | $self->parse_args( $req ); | |||||||||||||||||||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 0 | my $uri_restart = $self->uri_restart; | |||||||||||||||||||||||||||||||||||||||||||||
| 917 | 0 | my $content = <<TEXT; | |||||||||||||||||||||||||||||||||||||||||||||
| 918 | uri_restart: $uri_restart | ||||||||||||||||||||||||||||||||||||||||||||||
| 919 | TEXT | ||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 0 | xwarn "content=$content"; | |||||||||||||||||||||||||||||||||||||||||||||
| 921 | 0 | $resp->code( RC_OK ); | |||||||||||||||||||||||||||||||||||||||||||||
| 922 | 0 | $resp->content_type( 'text/plain' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 923 | 0 | $resp->content_length( length $content ); | |||||||||||||||||||||||||||||||||||||||||||||
| 924 | 0 | $resp->content( $content ); | |||||||||||||||||||||||||||||||||||||||||||||
| 925 | 0 | return RC_OK; | |||||||||||||||||||||||||||||||||||||||||||||
| 926 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||||||||||||||||||||
| 928 | |||||||||||||||||||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||||||||||||||||
| 930 | |||||||||||||||||||||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||||||||||||||||||||
| 933 | ############################################################################ | ||||||||||||||||||||||||||||||||||||||||||||||
| 934 | # Log handling | ||||||||||||||||||||||||||||||||||||||||||||||
| 935 | |||||||||||||||||||||||||||||||||||||||||||||||
| 936 | ############################################################ | ||||||||||||||||||||||||||||||||||||||||||||||
| 937 | sub build_logging | ||||||||||||||||||||||||||||||||||||||||||||||
| 938 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 6 | ▶ | my( $self, $args_log ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_logging: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 940 | |||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 6 | $self->{logging} = POE::XUL::Logging->new( $args_log, $self->{log_root} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 942 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 943 | |||||||||||||||||||||||||||||||||||||||||||||||
| 944 | ############################################################ | ||||||||||||||||||||||||||||||||||||||||||||||
| 945 | sub log_setup | ||||||||||||||||||||||||||||||||||||||||||||||
| 946 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 947 | 5 | ▶ | my( $self ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
log_setup: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 5 | $self->{logging}->setup; | |||||||||||||||||||||||||||||||||||||||||||||
| 949 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 950 | |||||||||||||||||||||||||||||||||||||||||||||||
| 951 | ############################################################ | ||||||||||||||||||||||||||||||||||||||||||||||
| 952 | sub sig_HUP | ||||||||||||||||||||||||||||||||||||||||||||||
| 953 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 0 | ▶ | my( $self ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sig_HUP: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 0 | xwarn "SIGHUP"; | |||||||||||||||||||||||||||||||||||||||||||||
| 956 | 0 | $poe_kernel->sig_handled(); | |||||||||||||||||||||||||||||||||||||||||||||
| 957 | |||||||||||||||||||||||||||||||||||||||||||||||
| 958 | 0 | $self->log_setup; | |||||||||||||||||||||||||||||||||||||||||||||
| 959 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 960 | |||||||||||||||||||||||||||||||||||||||||||||||
| 961 | |||||||||||||||||||||||||||||||||||||||||||||||
| 962 | ############################################################ | ||||||||||||||||||||||||||||||||||||||||||||||
| 963 | sub post_connection | ||||||||||||||||||||||||||||||||||||||||||||||
| 964 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 0 | ▶ | my( $self, $req, $resp ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
post_connection: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 0 | ▶ | my $app = eval { $req->param( 'app' ) } || $self->{logging}->{app}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
eval {
do {
$req->param('app')
}
} || $self->{'logging'}{'app'}
MC/DC0%0/2
eval {
do {
$req->param('app')
}
} || $self->{'logging'}{'app'}
eval {
do {
$req->param('app')
}
}
$self->{'logging'}{'app'}
Truth table0%0/3
A || B
A= eval {
do {
$req->param('app')
}
}B= $self->{'logging'}{'app'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 0 | local $self->{logging}->{app} = $app; | |||||||||||||||||||||||||||||||||||||||||||||
| 968 | |||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 0 | my $conn = $req->connection; | |||||||||||||||||||||||||||||||||||||||||||||
| 970 | 0 | my @log; | |||||||||||||||||||||||||||||||||||||||||||||
| 971 | 0 | ▶ | push @log, ($conn ? $conn->remote_ip : '0.0.0.0'); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 972 | 0 | ▶ | if( $log[-1] eq '127.0.0.1' and $req->header( 'X-Forwarded-For' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$log[-1] eq "127.0.0.1" and $req->header("X-Forwarded-For")
MC/DC0%0/2
$log[-1] eq "127.0.0.1" and $req->header("X-Forwarded-For")
$log[-1] eq "127.0.0.1"
$req->header("X-Forwarded-For")
Truth table0%0/3
A and B
A= $log[-1] eq "127.0.0.1"B= $req->header("X-Forwarded-For")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 973 | 0 | $log[-1] = $req->header( 'X-Forwarded-For' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 974 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 975 | # push @log, ($self->{preforked} ? $$ : '-'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 976 | 0 | push @log, $$, '-'; | |||||||||||||||||||||||||||||||||||||||||||||
| 977 | |||||||||||||||||||||||||||||||||||||||||||||||
| 978 | |||||||||||||||||||||||||||||||||||||||||||||||
| 979 | |||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 0 | my $path = $req->uri->path; | |||||||||||||||||||||||||||||||||||||||||||||
| 981 | 0 | my $query = $req->uri->query; | |||||||||||||||||||||||||||||||||||||||||||||
| 982 | 0 | ▶ | $path .= "?$query" if $query and $req->method eq 'GET'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$query and $req->method eq "GET"
MC/DC0%0/2
$query and $req->method eq "GET"
$query
$req->method eq "GET"
Truth table0%0/3
A and B
A= $queryB= $req->method eq "GET"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 983 | |||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 0 | push @log, "[". POSIX::strftime("%d/%m/%Y:%H:%M:%S %z", localtime)."]", | |||||||||||||||||||||||||||||||||||||||||||||
| 985 | join ' ', $req->method, $path; | ||||||||||||||||||||||||||||||||||||||||||||||
| 986 | 0 | $log[-1] = qq("$log[-1]"); | |||||||||||||||||||||||||||||||||||||||||||||
| 987 | 0 | ▶ | push @log, ($resp->code||'000'), ($resp->content_length||0); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
$resp->code || '000'
$resp->content_length || 0
MC/DC0%0/1
$resp->code || '000'
$resp->code
MC/DC0%0/1
$resp->content_length || 0
$resp->content_length
Truth table0%0/2
A
A= $resp->code
Truth table0%0/2
A
A= $resp->content_length
| |||||||||||||||||||||||||||||||||||||||||||||||
| 988 | |||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 0 | xlog( { message => join( ' ', @log )."\n", | |||||||||||||||||||||||||||||||||||||||||||||
| 990 | type => 'REQ' | ||||||||||||||||||||||||||||||||||||||||||||||
| 991 | } ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 992 | # use Devel::Cycle; | ||||||||||||||||||||||||||||||||||||||||||||||
| 993 | # find_cycle( $poe_kernel ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 994 | 0 | return RC_OK; | |||||||||||||||||||||||||||||||||||||||||||||
| 995 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 996 | |||||||||||||||||||||||||||||||||||||||||||||||
| 997 | |||||||||||||||||||||||||||||||||||||||||||||||
| 998 | |||||||||||||||||||||||||||||||||||||||||||||||
| 999 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 14 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 1001 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||