| 1 | |||||||||||||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # This file is part of WebDyne. | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # This software is copyright (c) 2026 by Andrew Speer <andrew.speer@isolutions.com.au>. | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||||||||||||
| 10 | # Full license text is available at: | ||||||||||||||||||||||||||||||||||||||||||
| 11 | # | ||||||||||||||||||||||||||||||||||||||||||
| 12 | # <http://dev.perl.org/licenses/> | ||||||||||||||||||||||||||||||||||||||||||
| 13 | # | ||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | package WebDyne::Request::Fake; | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | # Compiler Pragma | ||||||||||||||||||||||||||||||||||||||||||
| 20 | # | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 32 | ▶ | use strict qw(vars); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 32 | ▶ | use vars qw($VERSION $AUTOLOAD %Package); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 32 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 32 | ▶ | no warnings qw(uninitialized); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | # External modules | ||||||||||||||||||||||||||||||||||||||||||
| 28 | # | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 32 | ▶ | use Cwd qw(fastcwd); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 32 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 32 | ▶ | use HTTP::Status qw(status_message HTTP_OK HTTP_NOT_FOUND HTTP_FOUND); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 32 | ▶ | use HTTP::Headers::Fast; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 32 | ▶ | use HTTP::Negotiate qw(choose); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 32 | ▶ | use HTTP::AcceptLanguage; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 32 | ▶ | use HTTP::Headers::Util qw(split_header_words); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 32 | ▶ | use File::stat; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 32 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 32 | ▶ | use File::Spec::Unix; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 32 | ▶ | use WebDyne::Util; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 32 | ▶ | use WebDyne::Constant; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 32 | ▶ | use WebDyne::Request::Common qw(handler_methods_all handler_methods_check); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 32 | ▶ | use URI; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | # Version information | ||||||||||||||||||||||||||||||||||||||||||
| 46 | # | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 32 | $VERSION='3.029'; | |||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | # Debug load | ||||||||||||||||||||||||||||||||||||||||||
| 51 | # | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 32 | 0 && debug("Loading %s version $VERSION", __PACKAGE__); | |||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | # Run init code for utility accessors unless already done. Picked method() as arbitrary test | ||||||||||||||||||||||||||||||||||||||||||
| 56 | # | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 32 | ▶ | &init() unless defined(&method); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | # All done. Positive return | ||||||||||||||||||||||||||||||||||||||||||
| 61 | # | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 32 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | #================================================================================================== | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | 32 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=7 SCAR=29.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | # Do ENV filtering here | ||||||||||||||||||||||||||||||||||||||||||
| 72 | # | ||||||||||||||||||||||||||||||||||||||||||
| 73 | local %ENV=( | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 74 | (map { $_=>$ENV{$_} } ( | |||||||||||||||||||||||||||||||||||||||||
| 75 | 574 | grep { defined($ENV{$_}) } (qw( | |||||||||||||||||||||||||||||||||||||||||
| 76 | DOCUMENT_DEFAULT | ||||||||||||||||||||||||||||||||||||||||||
| 77 | DOCUMENT_ROOT | ||||||||||||||||||||||||||||||||||||||||||
| 78 | REQUEST_METHOD | ||||||||||||||||||||||||||||||||||||||||||
| 79 | REQUEST_URI | ||||||||||||||||||||||||||||||||||||||||||
| 80 | PATH_INFO | ||||||||||||||||||||||||||||||||||||||||||
| 81 | SCRIPT_NAME | ||||||||||||||||||||||||||||||||||||||||||
| 82 | QUERY_STRING | ||||||||||||||||||||||||||||||||||||||||||
| 83 | SERVER_PROTOCOL | ||||||||||||||||||||||||||||||||||||||||||
| 84 | SERVER_NAME | ||||||||||||||||||||||||||||||||||||||||||
| 85 | SERVER_PORT | ||||||||||||||||||||||||||||||||||||||||||
| 86 | REMOTE_ADDR | ||||||||||||||||||||||||||||||||||||||||||
| 87 | REMOTE_PORT | ||||||||||||||||||||||||||||||||||||||||||
| 88 | REMOTE_USER | ||||||||||||||||||||||||||||||||||||||||||
| 89 | AUTH_TYPE | ||||||||||||||||||||||||||||||||||||||||||
| 90 | HTTPS | ||||||||||||||||||||||||||||||||||||||||||
| 91 | APPL_MD_PATH | ||||||||||||||||||||||||||||||||||||||||||
| 92 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 93 | 1162 | (grep {/^WEBDYNE/i} keys %ENV), # Note not WEBDYNE_, just /WEBDYNE/i to allow for DirConfig type entries such as WebDyneHandler | |||||||||||||||||||||||||||||||||||||||||
| 94 | 1162 | (grep {/^HTTP_/i} keys %ENV), | |||||||||||||||||||||||||||||||||||||||||
| 95 | 32 | (grep {/^CONTENT_/i} keys %ENV) | |||||||||||||||||||||||||||||||||||||||||
| 96 | ))) | ||||||||||||||||||||||||||||||||||||||||||
| 97 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | # Setup pass through methods | ||||||||||||||||||||||||||||||||||||||||||
| 101 | # | ||||||||||||||||||||||||||||||||||||||||||
| 102 | my %method=( | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | accept_encoding => sub { shift()->headers_in('accept-encoding') }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | accept_language => sub { shift()->headers_in('accept-language') }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | accept => sub { shift()->headers_in('accept') }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 255 | ▶ | args => sub { shift()->env->{'QUERY_STRING'} }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | as_string => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | authority => sub { shift()->uri->authority }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | authorization => sub { shift()->headers_in('authorization') }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | auth_type => sub { shift()->{'env'}->{'AUTH_TYPE'} }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | base => 'base_url', | ||||||||||||||||||||||||||||||||||||||||||
| 112 | #base_url => sub { URI->new($_[0]->host . $_[0]->script_name()) }, | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | base_url => sub { my $uri_or=shift()->uri->canonical->clone; $uri_or->path('/'), $uri_or->query(undef); $uri_or }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | body_handle => sub { shift->{'input'} }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | body => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | cache_control => sub { shift()->headers_in('cache-control') }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | charset => sub { my $content_type=shift()->content_type || return; (my @split=split_header_words($content_type)) || return; my %param=@{$split[0]}; return lc($param{'charset'}) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
Branch: 1 branch
Condition0%0/2
(shift())->content_type || (return)
MC/DC0%0/1
(shift())->content_type || (return)
(shift())->content_type
Truth table0%0/2
A
A= (shift())->content_type
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | cleanup_register => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | client_address => sub { shift()->env->{'REMOTE_ADDR'} }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | content => 'body', | ||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | content_encoding => sub { shift()->headers_in('content-encoding') }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | content_length => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 123 | content_type => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 124 | cookie => 'cookies', | ||||||||||||||||||||||||||||||||||||||||||
| 125 | cookies => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 126 | custom_response => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 127 | cwd => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 128 | dir_config => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 129 | document_root => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 130 | 516 | ▶ | env => sub { \%ENV }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | etag => sub { shift()->headers_out('etag', @_) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | filename => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 133 | finalize => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 134 | finfo => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 135 | form_parameters => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | forwarded_for => sub { shift()->headers_in('x-forwarded-for') }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | fragment => sub { shift()->uri->fragment }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | handler => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 139 | header => 'headers_in', | ||||||||||||||||||||||||||||||||||||||||||
| 140 | headers => 'headers_in', | ||||||||||||||||||||||||||||||||||||||||||
| 141 | header_only => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 142 | headers_in => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 143 | headers_out => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | hostname => sub { shift()->env->{'SERVER_NAME'} }, # Prob should be local host name | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | #host => sub { shift()->uri->host if $_[0]->uri->authority }, | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | host => sub { shift()->headers_in('host') }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | https => sub { shift()->env->{'HTTPS'} }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | http_version => 'protocol', | ||||||||||||||||||||||||||||||||||||||||||
| 149 | id => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | if_modified_since => sub { shift()->headers_in('if-modified-since') }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | if_none_match => sub { shift()->headers_in('if-none-match') }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | input => sub { shift()->{'input'} }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | is_ajax => sub { (shift()->headers_in('x-requested-with') eq 'XMLHttpRequest') }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | is_main => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 155 | location => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 156 | log_error => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 157 | lookup_file => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 158 | lookup_uri => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 159 | main => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | media_type => sub { my $content_type=shift()->content_type || return; (my @split=split_header_words($content_type)) || return; return lc($split[0][0]) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
Branch: 1 branch
Condition0%0/2
(shift())->content_type || (return)
MC/DC0%0/1
(shift())->content_type || (return)
(shift())->content_type
Truth table0%0/2
A
A= (shift())->content_type
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | 255 | ▶ | method => sub { shift->env->{'REQUEST_METHOD'} || 'GET' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | mtime => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 163 | multipart_parameters=> undef, | ||||||||||||||||||||||||||||||||||||||||||
| 164 | next => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 165 | notes => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | origin => sub { shift()->headers_in('origin') }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | output_filters => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | path_info => sub { shift->env->{'PATH_INFO'} }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | path_parameters => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 170 | path => 'path_info', | ||||||||||||||||||||||||||||||||||||||||||
| 171 | pool => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 172 | preferred_charset => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 173 | preferred_encoding => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 174 | preferred_language => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 175 | preferred_media_type=> undef, | ||||||||||||||||||||||||||||||||||||||||||
| 176 | prev => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 177 | print => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | protocol => sub { shift()->env->{'SERVER_PROTOCOL'} || 'HTTP/1.1' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | query_parameters => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 180 | query_string => 'args', | ||||||||||||||||||||||||||||||||||||||||||
| 181 | redirect => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | referer => sub { shift()->headers_in('referer') }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | register_cleanup => 'cleanup_register', | ||||||||||||||||||||||||||||||||||||||||||
| 184 | remote_address => 'client_address', | ||||||||||||||||||||||||||||||||||||||||||
| 185 | remote_host => 'client_address', | ||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | remote_port => sub { shift()->env->{'REMOTE_PORT'} }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | remote_user => 'user', | ||||||||||||||||||||||||||||||||||||||||||
| 188 | request_time => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 189 | route => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 190 | run => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 191 | scheme => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | script_name => sub { shift()->env->{'SCRIPT_NAME'} }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | secure => sub { (shift()->https eq 'on') }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | sendfile => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 195 | send_http_header => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | server_name => sub { shift()->env->{'SERVER_NAME'} }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | server_port => sub { shift()->env->{'SERVER_PORT'} }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | session_id => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 199 | session => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 200 | set_handlers => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 201 | status_line => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 202 | status => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | unparsed_uri => sub { shift()->filename() }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | uploads => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 205 | #uri => sub { $_[0]->{'uri'} ||= URI->new($_[0]->filename()) }, | ||||||||||||||||||||||||||||||||||||||||||
| 206 | uri => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 207 | url => 'uri', | ||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | user_agent => sub { shift()->headers_in('user-agent') }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | user => sub { shift()->env->{'REMOTE_USER'} }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | 32 | write => undef, | |||||||||||||||||||||||||||||||||||||||||
| 211 | err_html => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 212 | DESTROY => undef | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | # Not really valid here but setup anyway | ||||||||||||||||||||||||||||||||||||||||||
| 218 | # | ||||||||||||||||||||||||||||||||||||||||||
| 219 | 32 | foreach my $handler (qw(req res)) { | |||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | *{$handler}=sub { return shift() }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | # Now setup abstraction methods. Slightly different than PSGI, PAGI, Apache so just do it here | ||||||||||||||||||||||||||||||||||||||||||
| 225 | # | ||||||||||||||||||||||||||||||||||||||||||
| 226 | 32 | my %method_check; | |||||||||||||||||||||||||||||||||||||||||
| 227 | 32 | ▶ | while (my ($method, $dispatch)=each %method) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | 3424 | $method_check{$method}++; | |||||||||||||||||||||||||||||||||||||||||
| 229 | 3424 | ▶ | if (defined(*{sprintf('%s::%s', __PACKAGE__, $method)}{'CODE'})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | # Do nothing, defined here | ||||||||||||||||||||||||||||||||||||||||||
| 231 | # | ||||||||||||||||||||||||||||||||||||||||||
| 232 | 1792 | ▶ | warn("duplicate method for $method") if $dispatch; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 233 | 1792 | 0 && debug("skip $method, defined in this package"); | |||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||
| 236 | elsif (!defined($dispatch)) { | ||||||||||||||||||||||||||||||||||||||||||
| 237 | # Do nothing, will fall through | ||||||||||||||||||||||||||||||||||||||||||
| 238 | # | ||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | 0 && debug("skip $method, will inherit from Fake"); | |||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||
| 241 | elsif (ref($dispatch) eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||
| 242 | # Turn into method | ||||||||||||||||||||||||||||||||||||||||||
| 243 | # | ||||||||||||||||||||||||||||||||||||||||||
| 244 | 1216 | 0 && debug("setting method: $method to code ref: $dispatch"); | |||||||||||||||||||||||||||||||||||||||||
| 245 | 1216 | *{$method}=$dispatch; | |||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||
| 247 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 248 | # Existing method | ||||||||||||||||||||||||||||||||||||||||||
| 249 | # | ||||||||||||||||||||||||||||||||||||||||||
| 250 | 416 | 0 && debug("setting method: $method to dispatch: $dispatch"); | |||||||||||||||||||||||||||||||||||||||||
| 251 | 416 | ▶ | *{$method}=sub { shift()->$dispatch(@_) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | # Done, do runtime check and return, will warn if we have missed anything | ||||||||||||||||||||||||||||||||||||||||||
| 257 | # | ||||||||||||||||||||||||||||||||||||||||||
| 258 | 32 | return handler_methods_check(__PACKAGE__, \%method_check); | |||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | 1 | ▶ | sub uri { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uri: called CC=2 SCAR=9.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | 1 | ▶ | $_[0]->{'uri'} ||= URI->new($_[0]->filename()) | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$_[0]{"uri"} ||= "URI"->new($_[0]->filename)
MC/DC0%0/2
$_[0]{"uri"} ||= "URI"->new($_[0]->filename)
$_[0]{"uri"}
"URI"->new($_[0]->filename)
Truth table33%1/3
A ||= B
A= $_[0]{"uri"}B= "URI"->new($_[0]->filename)
| |||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | sub body { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
body: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | my $r=shift(); | |||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | return $r->{'body'} ||= do { | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$r->{"body"} ||= do {
if (my $fh = $r->{"input"}) {
seek $fh, 0, 0;
local $/;
readline $fh;
}
}
MC/DC0%0/2
$r->{"body"} ||= do {
if (my $fh = $r->{"input"}) {
seek $fh, 0, 0;
local $/;
readline $fh;
}
}
$r->{"body"}
do {
if (my $fh = $r->{"input"}) {
seek $fh, 0, 0;
local $/;
readline $fh;
}
}
Truth table0%0/3
A ||= B
A= $r->{"body"}B= do {
if (my $fh = $r->{"input"}) {
seek $fh, 0, 0;
local $/;
readline $fh;
}
}
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | if (my $fh=$r->{'input'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | seek($fh,0,0); | |||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | local $/; | |||||||||||||||||||||||||||||||||||||||||
| 277 | <$fh> | ||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 279 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | sub cookies { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cookies: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | my $r=shift(); | |||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | require CGI::Simple::Cookie; | |||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | my %cookies=CGI::Simple::Cookie->parse( | |||||||||||||||||||||||||||||||||||||||||
| 289 | $r->headers_in('cookie')); | ||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | $r->headers_out('set-cookie', CGI::Simple::Cookie->new(@_)->as_string()); | |||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | return \%cookies; | |||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | 1656 | ▶ | sub dir_config { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dir_config: called CC=19 SCAR=33.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | # Newer more comprehensive dir_config that pulls from WEBDYNE_CONF | ||||||||||||||||||||||||||||||||||||||||||
| 301 | # | ||||||||||||||||||||||||||||||||||||||||||
| 302 | 1656 | my ($r, $key)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 303 | 1656 | 0 && debug("r: $r, caller: %s", Dumper([caller(0)])); | |||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | # Get hash ref from config file | ||||||||||||||||||||||||||||||||||||||||||
| 307 | # | ||||||||||||||||||||||||||||||||||||||||||
| 308 | 1656 | my $constant_hr=$WEBDYNE_DIR_CONFIG; | |||||||||||||||||||||||||||||||||||||||||
| 309 | 1656 | 0 && debug('using constant_hr: %s', Dumper($constant_hr)); | |||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | # Optionally load WEBDYNE_DIR_CONFIG from current dir | ||||||||||||||||||||||||||||||||||||||||||
| 313 | # | ||||||||||||||||||||||||||||||||||||||||||
| 314 | 1656 | ▶ | if ($WEBDYNE_DIR_CONFIG_CWD_LOAD) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | # Yes, wanted. Get cwd, skip if already processed | ||||||||||||||||||||||||||||||||||||||||||
| 318 | # | ||||||||||||||||||||||||||||||||||||||||||
| 319 | 1656 | my $cwd_dn=$r->cwd(); | |||||||||||||||||||||||||||||||||||||||||
| 320 | 1656 | ▶ | my $dir_config_hr=($Package{'_dir_config'}{$cwd_dn} ||= do { | ||||||||||||||||||||||||||||||||||||||||
|
Condition60%3/5
$WebDyne::Request::Fake::Package{"_dir_config"}{$cwd_dn} ||= do {
my $webdyne_conf_fn = "File::Spec"->catfile($cwd_dn, sprintf('.%s', $WebDyne::Request::Fake::WEBDYNE_CONF_FN));
'???';
if (-f $webdyne_conf_fn) {
'???';
my $webdyne_conf_hr = do $webdyne_conf_fn || warn("unable to read document root dir_config constant file, $!");
'???';
$webdyne_conf_hr->{"WebDyne::Constant"}{"WEBDYNE_DIR_CONFIG"};
}
} || {}
do {
my $webdyne_conf_fn = 'File::Spec'->catfile($cwd_dn, sprintf('.%s', $WebDyne::Request::Fake::WEBDYNE_CONF_FN));
'???';
if (-f $webdyne_conf_fn) {
'???';
my $webdyne_conf_hr = do $webdyne_conf_fn || warn("unable to read document root dir_config constant file, $!");
'???';
$webdyne_conf_hr->{'WebDyne::Constant'}{'WEBDYNE_DIR_CONFIG'};
}
} || {}
MC/DC0%0/2
$WebDyne::Request::Fake::Package{"_dir_config"}{$cwd_dn} ||= do {
my $webdyne_conf_fn = "File::Spec"->catfile($cwd_dn, sprintf('.%s', $WebDyne::Request::Fake::WEBDYNE_CONF_FN));
'???';
if (-f $webdyne_conf_fn) {
'???';
my $webdyne_conf_hr = do $webdyne_conf_fn || warn("unable to read document root dir_config constant file, $!");
'???';
$webdyne_conf_hr->{"WebDyne::Constant"}{"WEBDYNE_DIR_CONFIG"};
}
} || {}
$WebDyne::Request::Fake::Package{"_dir_config"}{$cwd_dn}
do {
my $webdyne_conf_fn = 'File::Spec'->catfile($cwd_dn, sprintf('.%s', $WebDyne::Request::Fake::WEBDYNE_CONF_FN));
'???';
if (-f $webdyne_conf_fn) {
'???';
my $webdyne_conf_hr = do $webdyne_conf_fn || warn("unable to read document root dir_config constant file, $!");
'???';
$webdyne_conf_hr->{'WebDyne::Constant'}{'WEBDYNE_DIR_CONFIG'};
}
}
Truth table33%1/3
A ||= B
A= $WebDyne::Request::Fake::Package{"_dir_config"}{$cwd_dn}B= do {
my $webdyne_conf_fn = 'File::Spec'->catfile($cwd_dn, sprintf('.%s', $WebDyne::Request::Fake::WEBDYNE_CONF_FN));
'???';
if (-f $webdyne_conf_fn) {
'???';
my $webdyne_conf_hr = do $webdyne_conf_fn || warn("unable to read document root dir_config constant file, $!");
'???';
$webdyne_conf_hr->{'WebDyne::Constant'}{'WEBDYNE_DIR_CONFIG'};
}
}
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | 22 | my $webdyne_conf_fn=File::Spec->catfile($cwd_dn, sprintf('.%s', $WEBDYNE_CONF_FN)); | |||||||||||||||||||||||||||||||||||||||||
| 322 | 22 | 0 && debug("fn: $webdyne_conf_fn"); | |||||||||||||||||||||||||||||||||||||||||
| 323 | 22 | ▶ | if (-f $webdyne_conf_fn) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | 0 && debug("found: $webdyne_conf_fn, reading"); | |||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | ▶ | my $webdyne_conf_hr=do($webdyne_conf_fn) || | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
do $webdyne_conf_fn || warn("unable to read document root dir_config constant file, $!")
MC/DC0%0/1
do $webdyne_conf_fn || warn("unable to read document root dir_config constant file, $!")
do $webdyne_conf_fn
Truth table0%0/2
A
A= do $webdyne_conf_fn
| |||||||||||||||||||||||||||||||||||||||||||
| 326 | warn "unable to read document root dir_config constant file, $!"; | ||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | 0 && debug('webdyne_conf_hr: %s', Dumper($webdyne_conf_hr)); | |||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | $webdyne_conf_hr->{'WebDyne::Constant'}{'WEBDYNE_DIR_CONFIG'}; | |||||||||||||||||||||||||||||||||||||||||
| 329 | }} || {} | ||||||||||||||||||||||||||||||||||||||||||
| 330 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 331 | 1656 | ▶ | if (keys %{$dir_config_hr}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 332 | $constant_hr={ | ||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | %{$constant_hr}, | |||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | %{$dir_config_hr} | |||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | # OK - heirarchy is this: | ||||||||||||||||||||||||||||||||||||||||||
| 341 | # | ||||||||||||||||||||||||||||||||||||||||||
| 342 | # If WEBDYNE_PSGI_DIR_CONFIG=$hr order of return | ||||||||||||||||||||||||||||||||||||||||||
| 343 | # | ||||||||||||||||||||||||||||||||||||||||||
| 344 | # $ENV{$key} # Wins everything | ||||||||||||||||||||||||||||||||||||||||||
| 345 | # $hr->{$servername}{$location}{$key} | ||||||||||||||||||||||||||||||||||||||||||
| 346 | # $hr->{$servername}{''}{$key} | ||||||||||||||||||||||||||||||||||||||||||
| 347 | # $hr->{$servername}{$key} | ||||||||||||||||||||||||||||||||||||||||||
| 348 | # $hr->{$location}{$key} | ||||||||||||||||||||||||||||||||||||||||||
| 349 | # $hr->{''}{$key} | ||||||||||||||||||||||||||||||||||||||||||
| 350 | # $hr->{$key} | ||||||||||||||||||||||||||||||||||||||||||
| 351 | # | ||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||
| 353 | 1656 | ▶ | if ($key) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | # Key specified, returning just that value | ||||||||||||||||||||||||||||||||||||||||||
| 356 | # | ||||||||||||||||||||||||||||||||||||||||||
| 357 | #if (exists $Dir_config_env{$key}) { | ||||||||||||||||||||||||||||||||||||||||||
| 358 | 1655 | ▶ | if (exists $ENV{$key}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||
| 360 | # $ENV{$key} # Wins everything | ||||||||||||||||||||||||||||||||||||||||||
| 361 | # | ||||||||||||||||||||||||||||||||||||||||||
| 362 | #debug('found $ENV{%s}, returning %s', $key, $Dir_config_env{$key}); | ||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | 0 && debug('found $ENV{%s}, returning %s', $key, $ENV{$key}); | |||||||||||||||||||||||||||||||||||||||||
| 364 | #return $Dir_config_env{$key}; | ||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | return $ENV{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||
| 368 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||
| 371 | # Get location we are operating in | ||||||||||||||||||||||||||||||||||||||||||
| 372 | # | ||||||||||||||||||||||||||||||||||||||||||
| 373 | 1655 | my $location=$r->location(); | |||||||||||||||||||||||||||||||||||||||||
| 374 | 1655 | 0 && debug("in dir_config looking for key: $key at location: $location"); | |||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||
| 377 | # Array of hashes we may need to look through | ||||||||||||||||||||||||||||||||||||||||||
| 378 | # | ||||||||||||||||||||||||||||||||||||||||||
| 379 | 1655 | my @constant_hr=($constant_hr); | |||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | # Do we have $hr->{$servername}{$location} ? | ||||||||||||||||||||||||||||||||||||||||||
| 383 | # | ||||||||||||||||||||||||||||||||||||||||||
| 384 | 1655 | ▶ | if (my $server=($ENV{'WebDyneServer'} || $ENV{'HOSTNAME'} || $ENV{'SERVER_NAME'})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$ENV{'WebDyneServer'} || $ENV{'HOSTNAME'} || $ENV{'SERVER_NAME'}
$ENV{"WebDyneServer"} or $ENV{"HOSTNAME"}
MC/DC0%0/3
$ENV{'WebDyneServer'} || $ENV{'HOSTNAME'} || $ENV{'SERVER_NAME'}
$ENV{"WebDyneServer"}
$ENV{"HOSTNAME"}
$ENV{'SERVER_NAME'}
Truth table50%2/4
A or B || C
A= $ENV{"WebDyneServer"}B= $ENV{"HOSTNAME"}C= $ENV{'SERVER_NAME'}
| |||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||
| 386 | # Have $servername | ||||||||||||||||||||||||||||||||||||||||||
| 387 | # | ||||||||||||||||||||||||||||||||||||||||||
| 388 | 1655 | 0 && debug("using server: $server"); | |||||||||||||||||||||||||||||||||||||||||
| 389 | 1655 | ▶ | if (exists $constant_hr->{$server}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | # Add to array of hashes we have to look at | ||||||||||||||||||||||||||||||||||||||||||
| 392 | # | ||||||||||||||||||||||||||||||||||||||||||
| 393 | 1 | unshift @constant_hr, (my $constant_server_hr=$constant_hr->{$server}); | |||||||||||||||||||||||||||||||||||||||||
| 394 | 1 | 0 && debug("pushing $constant_server_hr onto dir_config review stack: %s", Dumper($constant_server_hr)); | |||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | # Now iterate across array, return on first match | ||||||||||||||||||||||||||||||||||||||||||
| 402 | # | ||||||||||||||||||||||||||||||||||||||||||
| 403 | 1655 | foreach my $hr (@constant_hr) { | |||||||||||||||||||||||||||||||||||||||||
| 404 | 1655 | my %location; | |||||||||||||||||||||||||||||||||||||||||
| 405 | 1655 | foreach my $hr_key ($location, '') { | |||||||||||||||||||||||||||||||||||||||||
| 406 | 3308 | ▶ | next if ($location{$location}++); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 407 | 1655 | 0 && debug("looking at hr: $hr, hr_key: $hr_key"); | |||||||||||||||||||||||||||||||||||||||||
| 408 | # Maybe $hr->{$location}{$key} or $hr->{''}{$key} ? | ||||||||||||||||||||||||||||||||||||||||||
| 409 | # | ||||||||||||||||||||||||||||||||||||||||||
| 410 | 1655 | ▶ | if (exists $constant_hr->{$hr_key}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 411 | 2 | 0 && debug("found hr: $hr, hr_key: $hr_key"); | |||||||||||||||||||||||||||||||||||||||||
| 412 | 2 | ▶ | return $hr->{$hr_key}{$key} if exists($hr->{$hr_key}{$key}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||
| 414 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 415 | 1653 | 0 && debug("no match on hr: $hr, hr_key: $hr_key"); | |||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||
| 418 | # No - $hr->{$key} is last chance | ||||||||||||||||||||||||||||||||||||||||||
| 419 | # | ||||||||||||||||||||||||||||||||||||||||||
| 420 | 1653 | ▶ | if (exists $hr->{$key}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | 0 && debug("found hr: $hr, key: $key"); | |||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | return $hr->{$key} | |||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||
| 424 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 425 | 1653 | 0 && debug("no match on hr: $hr, key: $key"); | |||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||
| 429 | # Nothing found | ||||||||||||||||||||||||||||||||||||||||||
| 430 | # | ||||||||||||||||||||||||||||||||||||||||||
| 431 | 1653 | 0 && debug("no key found for location: $location or any other match"); | |||||||||||||||||||||||||||||||||||||||||
| 432 | 1653 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||
| 437 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||
| 439 | # Return dump of whole thing with ENV vars taking precendence at top level. Scrub mixing in ENV at moment, exposes | ||||||||||||||||||||||||||||||||||||||||||
| 440 | # too many non WebDyne vars if called with dir_config(). Do properly with Plack::Middleware::AddEnv or similar later | ||||||||||||||||||||||||||||||||||||||||||
| 441 | # | ||||||||||||||||||||||||||||||||||||||||||
| 442 | #my %dir_config=(%{$constant_hr}, %Dir_config_env); | ||||||||||||||||||||||||||||||||||||||||||
| 443 | my %dir_config=( | ||||||||||||||||||||||||||||||||||||||||||
| 444 | 1 | %{$constant_hr}, | |||||||||||||||||||||||||||||||||||||||||
| 445 | 1 | (map { $_=>$ENV{$_} } grep {/^WEBDYNE_/i} keys %ENV), | |||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | (map { $_=>$ENV{$_} } grep {exists $ENV{$_} } keys %{$constant_hr}) | |||||||||||||||||||||||||||||||||||||||||
| 447 | #(map { $_=>$ENV{$_} } @{$WEBDYNE_PSGI_ENV_KEEP}, | ||||||||||||||||||||||||||||||||||||||||||
| 448 | #%{$WEBDYNE_PSGI_ENV_SET} | ||||||||||||||||||||||||||||||||||||||||||
| 449 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 450 | 1 | return \%dir_config; | |||||||||||||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||
| 456 | 909 | ▶ | sub filename { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
filename: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||
| 458 | 909 | my $r=shift(); | |||||||||||||||||||||||||||||||||||||||||
| 459 | 909 | ▶ | return undef unless defined $r->{'filename'}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||
| 461 | # Store cwd as takes a fair bit of processing time. | ||||||||||||||||||||||||||||||||||||||||||
| 462 | 907 | ▶ | File::Spec->rel2abs($r->{'filename'}, ($Package{'_cwd'} ||= fastcwd())); | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$WebDyne::Request::Fake::Package{"_cwd"} ||= fastcwd()
MC/DC0%0/2
$WebDyne::Request::Fake::Package{"_cwd"} ||= fastcwd()
$WebDyne::Request::Fake::Package{"_cwd"}
fastcwd()
Truth table66%2/3
A ||= B
A= $WebDyne::Request::Fake::Package{"_cwd"}B= fastcwd()
| |||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||
| 467 | 1057 | ▶ | sub headers_in { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
headers_in: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 468 | 1057 | my $r=shift(); | |||||||||||||||||||||||||||||||||||||||||
| 469 | 1057 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 470 | 1027 | ▶ | return ($r->{'headers_in'} ||= HTTP::Headers::Fast->new())->header(@_); | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$r->{"headers_in"} ||= "HTTP::Headers::Fast"->new
MC/DC0%0/2
$r->{"headers_in"} ||= "HTTP::Headers::Fast"->new
$r->{"headers_in"}
"HTTP::Headers::Fast"->new
Truth table66%2/3
A ||= B
A= $r->{"headers_in"}B= "HTTP::Headers::Fast"->new
| |||||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||
| 472 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 473 | 30 | ▶ | return ($r->{'headers_in'} ||= HTTP::Headers::Fast->new()); | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$r->{"headers_in"} ||= "HTTP::Headers::Fast"->new
MC/DC0%0/2
$r->{"headers_in"} ||= "HTTP::Headers::Fast"->new
$r->{"headers_in"}
"HTTP::Headers::Fast"->new
Truth table66%2/3
A ||= B
A= $r->{"headers_in"}B= "HTTP::Headers::Fast"->new
| |||||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||
| 478 | 2668 | ▶ | sub headers_out { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
headers_out: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 479 | 2668 | my $r=shift(); | |||||||||||||||||||||||||||||||||||||||||
| 480 | 2668 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 481 | 2353 | ▶ | return ($r->{'headers_out'} ||= HTTP::Headers::Fast->new())->header(@_); | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$r->{"headers_out"} ||= "HTTP::Headers::Fast"->new
MC/DC0%0/2
$r->{"headers_out"} ||= "HTTP::Headers::Fast"->new
$r->{"headers_out"}
"HTTP::Headers::Fast"->new
Truth table66%2/3
A ||= B
A= $r->{"headers_out"}B= "HTTP::Headers::Fast"->new
| |||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||
| 483 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 484 | 315 | ▶ | return ($r->{'headers_out'} ||= HTTP::Headers::Fast->new()); | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$r->{"headers_out"} ||= "HTTP::Headers::Fast"->new
MC/DC0%0/2
$r->{"headers_out"} ||= "HTTP::Headers::Fast"->new
$r->{"headers_out"}
"HTTP::Headers::Fast"->new
Truth table66%2/3
A ||= B
A= $r->{"headers_out"}B= "HTTP::Headers::Fast"->new
| |||||||||||||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | ▶ | sub is_main { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_main: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | my $r=shift(); | |||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | ▶ | $r->{'main'} ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||
| 497 | 3 | ▶ | sub log_error { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
log_error: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||
| 499 | 3 | my $r=shift(); | |||||||||||||||||||||||||||||||||||||||||
| 500 | 3 | ▶ | warn(@_) unless !$r->{'warn'}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||
| 506 | 6 | ▶ | sub lookup_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lookup_file: called CC=4 SCAR=15.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||
| 508 | 6 | my ($r, $fn)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 509 | 6 | 0 && debug("r: $r, fn: $fn"); | |||||||||||||||||||||||||||||||||||||||||
| 510 | 6 | my $r_child; | |||||||||||||||||||||||||||||||||||||||||
| 511 | 6 | ▶ | if ($fn!~WEBDYNE_PSP_EXT_RE) { # fastest | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||
| 514 | # Static file. The helper retains its historical PSGI name but does | ||||||||||||||||||||||||||||||||||||||||||
| 515 | # not require Plack. | ||||||||||||||||||||||||||||||||||||||||||
| 516 | # | ||||||||||||||||||||||||||||||||||||||||||
| 517 | 6 | 0 && debug('non psp file, passing to WebDyne::Request::PSGI::Static'); | |||||||||||||||||||||||||||||||||||||||||
| 518 | 6 | require WebDyne::Request::PSGI::Static; | |||||||||||||||||||||||||||||||||||||||||
| 519 | 6 | ▶ | $r_child=WebDyne::Request::PSGI::Static->new(filename => $fn, prev => $r, env=>$r->env()) || | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
'WebDyne::Request::PSGI::Static'->new('filename', $fn, 'prev', $r, 'env', $r->env) || (return err())
MC/DC0%0/1
'WebDyne::Request::PSGI::Static'->new('filename', $fn, 'prev', $r, 'env', $r->env) || (return err())
'WebDyne::Request::PSGI::Static'->new('filename', $fn, 'prev', $r, 'env', $r->env)
Truth table50%1/2
A
A= 'WebDyne::Request::PSGI::Static'->new('filename', $fn, 'prev', $r, 'env', $r->env)
| |||||||||||||||||||||||||||||||||||||||||||
| 520 | return err(); | ||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||||||||||||
| 523 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||
| 526 | # Subrequest | ||||||||||||||||||||||||||||||||||||||||||
| 527 | # | ||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | 0 && debug('psp file, creating new request'); | |||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | ▶ | $r_child=ref($r)->new(filename => $fn, prev => $r) || return err(); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
ref($r)->new('filename', $fn, 'prev', $r) || (return err())
MC/DC0%0/1
ref($r)->new('filename', $fn, 'prev', $r) || (return err())
ref($r)->new('filename', $fn, 'prev', $r)
Truth table0%0/2
A
A= ref($r)->new('filename', $fn, 'prev', $r)
| |||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||
| 533 | # Return child | ||||||||||||||||||||||||||||||||||||||||||
| 534 | # | ||||||||||||||||||||||||||||||||||||||||||
| 535 | 6 | 0 && debug("returning r_child: $r_child"); | |||||||||||||||||||||||||||||||||||||||||
| 536 | 6 | return $r_child; | |||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | ▶ | sub lookup_uri { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lookup_uri: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | my ($r, $uri)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | my $fn=File::Spec::Unix->catfile((File::Spec->splitpath($r->filename()))[1], $uri); | |||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | return $r->lookup_file($fn); | |||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||
| 550 | 301 | ▶ | sub main { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
main: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||
| 552 | 301 | my $r=shift(); | |||||||||||||||||||||||||||||||||||||||||
| 553 | #@_ ? $r->{'main'}=shift() : $r->{'main'} || $r; | ||||||||||||||||||||||||||||||||||||||||||
| 554 | 301 | ▶ | @_ ? $r->{'main'}=shift() : $r->{'main'}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||
| 559 | 445 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=16.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||
| 562 | # Instantiate new fake handler | ||||||||||||||||||||||||||||||||||||||||||
| 563 | # | ||||||||||||||||||||||||||||||||||||||||||
| 564 | 445 | my ($class, %r)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 565 | 445 | 0 && debug("$class, r:%s", Dumper(\%r)); | |||||||||||||||||||||||||||||||||||||||||
| 566 | 445 | my $r=bless(\%r, $class); | |||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||
| 569 | # Now move ENV into headers | ||||||||||||||||||||||||||||||||||||||||||
| 570 | # | ||||||||||||||||||||||||||||||||||||||||||
| 571 | 445 | foreach my $env ((grep {/^HTTP_/} keys %ENV), qw(CONTENT_TYPE CONTENT_LENGTH)) { | |||||||||||||||||||||||||||||||||||||||||
| 572 | 890 | my $header=$env; | |||||||||||||||||||||||||||||||||||||||||
| 573 | 890 | ▶ | exists $ENV{$header} || next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 574 | 6 | my $value=$ENV{$header}; | |||||||||||||||||||||||||||||||||||||||||
| 575 | 6 | $header=~s/^HTTP_//; | |||||||||||||||||||||||||||||||||||||||||
| 576 | 6 | $header=~s/_/-/g; | |||||||||||||||||||||||||||||||||||||||||
| 577 | 6 | 0 && debug("setting header: $header, value: $value"); | |||||||||||||||||||||||||||||||||||||||||
| 578 | 6 | $r->headers_in(lc($header), $value); | |||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||
| 582 | # If Headers in supplied as array or hash ref convert | ||||||||||||||||||||||||||||||||||||||||||
| 583 | # | ||||||||||||||||||||||||||||||||||||||||||
| 584 | 445 | ▶ | if (ref($r{'headers_in'}) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | $r{'headers_in'}=HTTP::Headers::Fast->new(@{$r->{'headers_in'}}) | |||||||||||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||||||||||||
| 587 | elsif (ref($r{'headers_in'}) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | $r{'headers_in'}=HTTP::Headers::Fast->new(%{$r->{'headers_in'}}) | |||||||||||||||||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||
| 592 | # Done | ||||||||||||||||||||||||||||||||||||||||||
| 593 | # | ||||||||||||||||||||||||||||||||||||||||||
| 594 | 445 | return $r; | |||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | ▶ | sub notes { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
notes: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | my ($r, $k, $v)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | ▶ | if (@_ == 3) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | return $r->{'_notes'}{$k}=$v | |||||||||||||||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||||||||||||||||
| 605 | elsif (@_ == 2) { | ||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | return $r->{'_notes'}{$k} | |||||||||||||||||||||||||||||||||||||||||
| 607 | } | ||||||||||||||||||||||||||||||||||||||||||
| 608 | elsif (@_ == 1) { | ||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | ▶ | return ($r->{'_notes'} ||= {}); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$r->{"_notes"} ||= {}
MC/DC0%0/1
$r->{"_notes"} ||= {}
$r->{"_notes"}
Truth table0%0/2
A
A= $r->{"_notes"}
| |||||||||||||||||||||||||||||||||||||||||||
| 610 | } | ||||||||||||||||||||||||||||||||||||||||||
| 611 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | return err('incorrect usage of %s notes object, r->notes(%s)', +__PACKAGE__, join(',', @_[1..$#_])); | |||||||||||||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||
| 620 | 9 | ▶ | sub prev { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prev: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||
| 622 | 9 | my $r=shift(); | |||||||||||||||||||||||||||||||||||||||||
| 623 | 9 | ▶ | @_ ? $r->{'prev'}=shift() : $r->{'prev'}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||
| 628 | 305 | ▶ | sub print { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||
| 630 | 305 | my $r=shift(); | |||||||||||||||||||||||||||||||||||||||||
| 631 | 305 | ▶ | my $fh=$r->{'select'} || \*STDOUT; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$r->{'select'} || \*STDOUT
MC/DC0%0/1
$r->{'select'} || \*STDOUT
$r->{'select'}
Truth table50%1/2
A
A= $r->{'select'}
| |||||||||||||||||||||||||||||||||||||||||||
| 632 | 305 | 0 && debug("print fh: $fh"); | |||||||||||||||||||||||||||||||||||||||||
| 633 | 305 | ▶ | CORE::print $fh ((ref($_[0]) eq 'SCALAR') ? ${$_[0]} : @_); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||
| 635 | } | ||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||
| 638 | 139 | ▶ | sub cleanup_register { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cleanup_register: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||
| 640 | #my $r=shift(); | ||||||||||||||||||||||||||||||||||||||||||
| 641 | 139 | my ($r, $cr)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 642 | 139 | ▶ | push @{$r->{'register_cleanup'} ||= []}, $cr; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$r->{"register_cleanup"} ||= []
MC/DC0%0/1
$r->{"register_cleanup"} ||= []
$r->{"register_cleanup"}
Truth table50%1/2
A
A= $r->{"register_cleanup"}
| |||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||
| 644 | #my $ar=$r->{'register_cleanup'} ||= []; | ||||||||||||||||||||||||||||||||||||||||||
| 645 | #push @ | ||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||
| 647 | } | ||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | ▶ | sub pool { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pool: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||
| 654 | # Used by mod_perl2, usually for cleanup_register in the form of $r->pool->cleanup_register(), so just | ||||||||||||||||||||||||||||||||||||||||||
| 655 | # return $r and let the code then call cleanup_register | ||||||||||||||||||||||||||||||||||||||||||
| 656 | # | ||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | my $r=shift(); | |||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||
| 659 | } | ||||||||||||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | my ($r, $self)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | 0 && debug("r: $r, self: $self"); | |||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | ▶ | (ref($self) || $self)->handler($r); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table0%0/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||
| 667 | #(ref($self) ? $self : $self)->handler($r); | ||||||||||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||||||||||
| 669 | } | ||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||
| 672 | 317 | ▶ | sub status { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
status: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||
| 674 | 317 | my $r=shift(); | |||||||||||||||||||||||||||||||||||||||||
| 675 | 317 | ▶ | @_ ? $r->{'status'}=shift() : $r->{'status'} || HTTP_OK; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$r->{"status"} or 200
MC/DC100%1/1
$r->{"status"} or 200
$r->{"status"}
Truth table100%2/2
A
A= $r->{"status"}
| |||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||
| 677 | } | ||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||
| 680 | 2 | ▶ | sub document_root { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
document_root: called CC=4 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||
| 682 | 2 | my $r=shift(); | |||||||||||||||||||||||||||||||||||||||||
| 683 | 2 | ▶ | @_ ? $r->{'document_root'}=shift() : $r->{'document_root'} || ($ENV{'DOCUMENT_ROOT'} || fastcwd()); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$r->{"document_root"} or ($ENV{"DOCUMENT_ROOT"} or fastcwd())
$ENV{"DOCUMENT_ROOT"} or fastcwd()
MC/DC0%0/3
$r->{"document_root"} or ($ENV{"DOCUMENT_ROOT"} or fastcwd())
$r->{"document_root"}
$ENV{"DOCUMENT_ROOT"}
fastcwd()
Truth table25%1/4
A or B or C
A= $r->{"document_root"}B= $ENV{"DOCUMENT_ROOT"}C= fastcwd()
| |||||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||
| 685 | } | ||||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||
| 688 | 2 | ▶ | sub output_filters { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
output_filters: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||
| 690 | # Stub | ||||||||||||||||||||||||||||||||||||||||||
| 691 | } | ||||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||||||||||||||||
| 694 | 1973 | ▶ | sub location { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
location: called CC=15 SCAR=28.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||
| 697 | # Equiv to Apache::RequestUtil->location; | ||||||||||||||||||||||||||||||||||||||||||
| 698 | # | ||||||||||||||||||||||||||||||||||||||||||
| 699 | 1973 | my $r=shift(); | |||||||||||||||||||||||||||||||||||||||||
| 700 | 1973 | 0 && debug("r: $r, caller: %s", Dumper([caller(0)])); | |||||||||||||||||||||||||||||||||||||||||
| 701 | 1973 | my $location; | |||||||||||||||||||||||||||||||||||||||||
| 702 | 1973 | my $constant_hr=$WEBDYNE_DIR_CONFIG; | |||||||||||||||||||||||||||||||||||||||||
| 703 | 1973 | my $constant_server_hr; | |||||||||||||||||||||||||||||||||||||||||
| 704 | #if (my $server=$Dir_config_env{'WebDyneServer'} || $ENV{'SERVER_NAME'}) { | ||||||||||||||||||||||||||||||||||||||||||
| 705 | 1973 | ▶ | if (my $server=$ENV{'WebDyneServer'} || $ENV{'SERVER_NAME'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$ENV{'WebDyneServer'} || $ENV{'SERVER_NAME'}
MC/DC50%1/2
$ENV{'WebDyneServer'} || $ENV{'SERVER_NAME'}
$ENV{'WebDyneServer'}
$ENV{'SERVER_NAME'}
Truth table66%2/3
A || B
A= $ENV{'WebDyneServer'}B= $ENV{'SERVER_NAME'}
| |||||||||||||||||||||||||||||||||||||||||||
| 706 | 1 | ▶ | $constant_server_hr=$constant_hr->{$server} if exists($constant_hr->{$server}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 707 | } | ||||||||||||||||||||||||||||||||||||||||||
| 708 | #if ($Dir_config_env{'WebDyneLocation'} || $ENV{'APPL_MD_PATH'}) { | ||||||||||||||||||||||||||||||||||||||||||
| 709 | 1973 | ▶ | if ($location=$r->{'location'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 710 | 2 | return $location; | |||||||||||||||||||||||||||||||||||||||||
| 711 | } | ||||||||||||||||||||||||||||||||||||||||||
| 712 | ▶ | elsif ($ENV{'WebDyneLocation'} || $ENV{'APPL_MD_PATH'}) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$ENV{"WebDyneLocation"} or $ENV{"APPL_MD_PATH"}
MC/DC50%1/2
$ENV{"WebDyneLocation"} or $ENV{"APPL_MD_PATH"}
$ENV{"WebDyneLocation"}
$ENV{"APPL_MD_PATH"}
Truth table66%2/3
A or B
A= $ENV{"WebDyneLocation"}B= $ENV{"APPL_MD_PATH"}
| |||||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||
| 714 | # APPL_MD_PATH is IIS virtual dir. If that or a fixed location set use it. | ||||||||||||||||||||||||||||||||||||||||||
| 715 | # | ||||||||||||||||||||||||||||||||||||||||||
| 716 | #$location=$Dir_config_env{'WebDyneLocation'} || $ENV{'APPL_MD_PATH'}; | ||||||||||||||||||||||||||||||||||||||||||
| 717 | 1 | ▶ | $location=$ENV{'WebDyneLocation'} || $ENV{'APPL_MD_PATH'}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$ENV{'WebDyneLocation'} || $ENV{'APPL_MD_PATH'}
MC/DC0%0/2
$ENV{'WebDyneLocation'} || $ENV{'APPL_MD_PATH'}
$ENV{'WebDyneLocation'}
$ENV{'APPL_MD_PATH'}
Truth table33%1/3
A || B
A= $ENV{'WebDyneLocation'}B= $ENV{'APPL_MD_PATH'}
| |||||||||||||||||||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||||||||||||||||
| 719 | 3940 | elsif (my $uri_path=join('', grep {$_} @ENV{qw(SCRIPT_NAME PATH_INFO)})) { | |||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||
| 721 | # Strip file name | ||||||||||||||||||||||||||||||||||||||||||
| 722 | # | ||||||||||||||||||||||||||||||||||||||||||
| 723 | 1707 | $uri_path=~s{[^/]+\Q@{[WEBDYNE_PSP_EXT]}\E$}{}x; #\ | |||||||||||||||||||||||||||||||||||||||||
| 724 | 1707 | 0 && debug("uri_path: $uri_path"); | |||||||||||||||||||||||||||||||||||||||||
| 725 | 1707 | my @location=('/', grep {$_} File::Spec::Unix->splitdir($uri_path)); | |||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||
| 727 | # Start iterating through directories | ||||||||||||||||||||||||||||||||||||||||||
| 728 | # | ||||||||||||||||||||||||||||||||||||||||||
| 729 | 1707 | ▶ | while ($location=File::Spec::Unix->catdir(@location)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 730 | 1723 | 0 && debug("location: $location"); | |||||||||||||||||||||||||||||||||||||||||
| 731 | 1723 | ▶ | last if exists($constant_hr->{$location}) || exists($constant_server_hr->{$location}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $constant_hr->{$location} or exists $constant_server_hr->{$location}
MC/DC0%0/2
exists $constant_hr->{$location} or exists $constant_server_hr->{$location}
exists $constant_hr->{$location}
exists $constant_server_hr->{$location}
Truth table33%1/3
A or B
A= exists $constant_hr->{$location}B= exists $constant_server_hr->{$location}
| |||||||||||||||||||||||||||||||||||||||||||
| 732 | 1723 | ▶ | $location.='/' unless ($location eq '/'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 733 | 1723 | ▶ | last if exists($constant_hr->{$location}) || exists($constant_server_hr->{$location}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $constant_hr->{$location} or exists $constant_server_hr->{$location}
MC/DC0%0/2
exists $constant_hr->{$location} or exists $constant_server_hr->{$location}
exists $constant_hr->{$location}
exists $constant_server_hr->{$location}
Truth table33%1/3
A or B
A= exists $constant_hr->{$location}B= exists $constant_server_hr->{$location}
| |||||||||||||||||||||||||||||||||||||||||||
| 734 | 1723 | pop @location; | |||||||||||||||||||||||||||||||||||||||||
| 735 | } | ||||||||||||||||||||||||||||||||||||||||||
| 736 | } | ||||||||||||||||||||||||||||||||||||||||||
| 737 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||
| 739 | # Actually mod_perl spec says location blank if not positively given - don't default to '/' | ||||||||||||||||||||||||||||||||||||||||||
| 740 | # | ||||||||||||||||||||||||||||||||||||||||||
| 741 | #$location=File::Spec::Unix->rootdir(); | ||||||||||||||||||||||||||||||||||||||||||
| 742 | } | ||||||||||||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||||||||||||
| 744 | # | ||||||||||||||||||||||||||||||||||||||||||
| 745 | # | ||||||||||||||||||||||||||||||||||||||||||
| 746 | 1971 | return $location; | |||||||||||||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||||||||||||
| 748 | } | ||||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||||||||||
| 752 | 305 | ▶ | sub header_only { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header_only: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||
| 754 | # Stub | ||||||||||||||||||||||||||||||||||||||||||
| 755 | } | ||||||||||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||
| 758 | 3 | ▶ | sub set_handlers { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_handlers: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||||||||||||
| 760 | # Stub | ||||||||||||||||||||||||||||||||||||||||||
| 761 | } | ||||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||||||||||||
| 766 | 304 | ▶ | sub send_http_header { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send_http_header: called CC=4 SCAR=24.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||
| 768 | 304 | my $r=shift(); | |||||||||||||||||||||||||||||||||||||||||
| 769 | 304 | ▶ | return unless $r->{'header'}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 770 | 0 | ▶ | my $fh=$r->{'select'} || \*STDOUT; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$r->{'select'} || \*STDOUT
MC/DC0%0/1
$r->{'select'} || \*STDOUT
$r->{'select'}
Truth table0%0/2
A
A= $r->{'select'}
| |||||||||||||||||||||||||||||||||||||||||||
| 771 | 0 | CORE::printf $fh ("Status: %s\n", $r->status()); | |||||||||||||||||||||||||||||||||||||||||
| 772 | 0 | ▶ | while (my ($header, $value)=each(%{$r->headers_out()})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 773 | 0 | CORE::print $fh ("$header: $value\n"); | |||||||||||||||||||||||||||||||||||||||||
| 774 | } | ||||||||||||||||||||||||||||||||||||||||||
| 775 | 0 | CORE::print $fh "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||
| 777 | } | ||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||||||||||||
| 780 | 316 | ▶ | sub content_type { # Was bi-directional but now only reads from response headers. | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content_type: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||
| 782 | 316 | my ($r, $content_type)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 783 | 316 | 0 && debug("r: $r, %s", Dumper(\@_)); | |||||||||||||||||||||||||||||||||||||||||
| 784 | #return ($content_type ? $r->headers_out('content-type', $content_type) : $r->headers_in('content-type')); | ||||||||||||||||||||||||||||||||||||||||||
| 785 | 316 | ▶ | return ($content_type ? $r->headers_out('content-type', $content_type) : $r->headers_out('content-type')); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||||||||||||||||
| 787 | } | ||||||||||||||||||||||||||||||||||||||||||
| 788 | |||||||||||||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||||||||||||
| 790 | 255 | ▶ | sub content_length { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content_length: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||
| 792 | 255 | my ($r, $content_length)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 793 | 255 | 0 && debug("r: $r, %s", Dumper(\@_)); | |||||||||||||||||||||||||||||||||||||||||
| 794 | 255 | ▶ | return ($content_length ? $r->headers_out('content-length', $content_length) : $r->headers_in('content-length')); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||||||||||||||||
| 796 | } | ||||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||||
| 798 | |||||||||||||||||||||||||||||||||||||||||||
| 799 | 2 | ▶ | sub handler { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler: called CC=3 SCAR=12.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||
| 801 | # Replicate mod_perl handler function | ||||||||||||||||||||||||||||||||||||||||||
| 802 | # | ||||||||||||||||||||||||||||||||||||||||||
| 803 | 2 | my ($r, $handler)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 804 | 2 | ▶ | return ($handler ? $r->{'handler'}=$handler : $r->{'handler'} ||= 'default-handler'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$handler ? $r->{"handler"} = $handler : $r->{"handler"} ||= "default-handler"
MC/DC0%0/1
$handler ? $r->{"handler"} = $handler : $r->{"handler"} ||= "default-handler"
$handler ? $r->{"handler"} = $handler : $r->{"handler"}
Truth table50%1/2
A
A= $handler ? $r->{"handler"} = $handler : $r->{"handler"}
| |||||||||||||||||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||||||||||||||||
| 806 | } | ||||||||||||||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||||||||||
| 809 | 3 | ▶ | sub custom_response { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
custom_response: called CC=3 SCAR=12.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||||||||||
| 811 | 3 | my ($r, $status)=(shift(), shift()); | |||||||||||||||||||||||||||||||||||||||||
| 812 | 0 | ▶ | while ($r->prev) {$r=$r->prev} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 813 | 3 | 0 && debug("in custom response, status $status"); | |||||||||||||||||||||||||||||||||||||||||
| 814 | 3 | ▶ | @_ ? $r->{'custom_response'}{$status}=shift() : $r->{'custom_response'}{$status}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||||||||||||||||
| 816 | } | ||||||||||||||||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||
| 819 | 1656 | ▶ | sub cwd { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cwd: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||||||||||||
| 821 | # Return cwd of current psp file | ||||||||||||||||||||||||||||||||||||||||||
| 822 | # | ||||||||||||||||||||||||||||||||||||||||||
| 823 | 1656 | my $r=shift(); | |||||||||||||||||||||||||||||||||||||||||
| 824 | 1656 | ▶ | return $r->{'_cwd'} ||= do { | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$r->{"_cwd"} ||= do {
'???';
my $fn = $r->filename;
my $dn;
if (-d ($dn = "File::Spec"->rel2abs($fn))) {
'???';
$dn;
}
else {
$dn = ("File::Spec"->splitpath($fn))[1] || fastcwd();
'???';
$dn;
}
}
MC/DC0%0/2
$r->{"_cwd"} ||= do {
'???';
my $fn = $r->filename;
my $dn;
if (-d ($dn = "File::Spec"->rel2abs($fn))) {
'???';
$dn;
}
else {
$dn = ("File::Spec"->splitpath($fn))[1] || fastcwd();
'???';
$dn;
}
}
$r->{"_cwd"}
do {
'???';
my $fn = $r->filename;
my $dn;
if (-d ($dn = "File::Spec"->rel2abs($fn))) {
'???';
$dn;
}
else {
$dn = ("File::Spec"->splitpath($fn))[1] || fastcwd();
'???';
$dn;
}
}
Truth table66%2/3
A ||= B
A= $r->{"_cwd"}B= do {
'???';
my $fn = $r->filename;
my $dn;
if (-d ($dn = "File::Spec"->rel2abs($fn))) {
'???';
$dn;
}
else {
$dn = ("File::Spec"->splitpath($fn))[1] || fastcwd();
'???';
$dn;
}
}
| |||||||||||||||||||||||||||||||||||||||||||
| 825 | 423 | 0 && debug("$r, fn: %s", $r->filename()); | |||||||||||||||||||||||||||||||||||||||||
| 826 | 423 | my $fn=$r->filename(); | |||||||||||||||||||||||||||||||||||||||||
| 827 | 423 | my $dn; | |||||||||||||||||||||||||||||||||||||||||
| 828 | 423 | ▶ | unless (-d ($dn=File::Spec->rel2abs($fn))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 829 | # Not a directory, must be file | ||||||||||||||||||||||||||||||||||||||||||
| 830 | # | ||||||||||||||||||||||||||||||||||||||||||
| 831 | 421 | ▶ | $dn=(File::Spec->splitpath($fn))[1] || fastcwd(); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
('File::Spec'->splitpath($fn))[1] || fastcwd()
MC/DC0%0/2
('File::Spec'->splitpath($fn))[1] || fastcwd()
('File::Spec'->splitpath($fn))[1]
fastcwd()
Truth table33%1/3
A || B
A= ('File::Spec'->splitpath($fn))[1]B= fastcwd()
| |||||||||||||||||||||||||||||||||||||||||||
| 832 | 421 | 0 && debug("return calculated dn: $dn"); | |||||||||||||||||||||||||||||||||||||||||
| 833 | 421 | $dn; | |||||||||||||||||||||||||||||||||||||||||
| 834 | } | ||||||||||||||||||||||||||||||||||||||||||
| 835 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 836 | 2 | 0 && debug("return existing dn: $dn"); | |||||||||||||||||||||||||||||||||||||||||
| 837 | 2 | $dn; | |||||||||||||||||||||||||||||||||||||||||
| 838 | } | ||||||||||||||||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||||||||||||||||
| 840 | } | ||||||||||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||||||||||
| 842 | } | ||||||||||||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||||||||||||||||
| 845 | # TO DO | ||||||||||||||||||||||||||||||||||||||||||
| 846 | # | ||||||||||||||||||||||||||||||||||||||||||
| 847 | 0 | ▶ | sub status_line { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
status_line: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||||||||||||||||
| 849 | 0 | my $r=shift(); | |||||||||||||||||||||||||||||||||||||||||
| 850 | 0 | return sprintf('%s %s',$r->status, status_message($r->status)); | |||||||||||||||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||||||||||||||||
| 852 | } | ||||||||||||||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||||||||||||
| 854 | |||||||||||||||||||||||||||||||||||||||||||
| 855 | 0 | ▶ | sub write { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 856 | |||||||||||||||||||||||||||||||||||||||||||
| 857 | # Just print for Fake, other handlers can map to native | ||||||||||||||||||||||||||||||||||||||||||
| 858 | # | ||||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | return &print(@_); | |||||||||||||||||||||||||||||||||||||||||
| 860 | |||||||||||||||||||||||||||||||||||||||||||
| 861 | } | ||||||||||||||||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||||||||||||||||
| 863 | |||||||||||||||||||||||||||||||||||||||||||
| 864 | 0 | ▶ | sub finalize { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
finalize: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 865 | |||||||||||||||||||||||||||||||||||||||||||
| 866 | # No op | ||||||||||||||||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||||||||||||||||
| 868 | } | ||||||||||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||||||||||
| 870 | |||||||||||||||||||||||||||||||||||||||||||
| 871 | 0 | ▶ | sub redirect { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
redirect: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 872 | |||||||||||||||||||||||||||||||||||||||||||
| 873 | # No op | ||||||||||||||||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||||||||||||||||
| 875 | } | ||||||||||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||||||||||
| 877 | |||||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||
| 879 | 0 | ▶ | sub as_string { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | my $r=shift(); | |||||||||||||||||||||||||||||||||||||||||
| 882 | 0 | my @return; | |||||||||||||||||||||||||||||||||||||||||
| 883 | 0 | push @return, join(' ', map {$r->$_} qw(method unparsed_uri protocol)); | |||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | push @return, $r->headers_in->as_string(); | |||||||||||||||||||||||||||||||||||||||||
| 885 | 0 | push @return, undef; #Blank line between headers and body | |||||||||||||||||||||||||||||||||||||||||
| 886 | 0 | push @return, $r->body(); | |||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | return join("\n", grep {$_} @return); | |||||||||||||||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||||||||||||||||
| 889 | } | ||||||||||||||||||||||||||||||||||||||||||
| 890 | |||||||||||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||||||||||
| 892 | 0 | ▶ | sub mtime { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mtime: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||||||||||||
| 894 | 0 | shift()->finfo->mtime(); | |||||||||||||||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||||||||||||||||
| 896 | } | ||||||||||||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | ▶ | sub next { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||||||||||||||||
| 900 | } | ||||||||||||||||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||||||||||||||||
| 902 | |||||||||||||||||||||||||||||||||||||||||||
| 903 | 0 | ▶ | sub preferred_charset { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
preferred_charset: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||||||||||||
| 905 | 0 | return &preferred_media_type(@_); | |||||||||||||||||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||||||||||||||||
| 907 | } | ||||||||||||||||||||||||||||||||||||||||||
| 908 | |||||||||||||||||||||||||||||||||||||||||||
| 909 | 0 | ▶ | sub preferred_encoding { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
preferred_encoding: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 910 | |||||||||||||||||||||||||||||||||||||||||||
| 911 | 0 | return &preferred_media_type(@_); | |||||||||||||||||||||||||||||||||||||||||
| 912 | |||||||||||||||||||||||||||||||||||||||||||
| 913 | } | ||||||||||||||||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||||||||||||||||
| 916 | 0 | ▶ | sub preferred_language { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
preferred_language: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||||||||||||||||
| 918 | 0 | my ($r, $lang_ar, @param)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 919 | 0 | ▶ | unless (ref($lang_ar) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 920 | 0 | $lang_ar=[$lang_ar, @param]; | |||||||||||||||||||||||||||||||||||||||||
| 921 | } | ||||||||||||||||||||||||||||||||||||||||||
| 922 | 0 | return HTTP::AcceptLanguage->new($r->accept_language())->match(@{$lang_ar}); | |||||||||||||||||||||||||||||||||||||||||
| 923 | |||||||||||||||||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||||||||||||||||
| 925 | } | ||||||||||||||||||||||||||||||||||||||||||
| 926 | |||||||||||||||||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||||||||||||||||
| 928 | 0 | ▶ | sub preferred_media_type { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
preferred_media_type: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||||||||||||
| 930 | 0 | my ($r, $variant_ar, @param)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 931 | 0 | ▶ | unless (ref($variant_ar) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 932 | 0 | $variant_ar=[map {[$_]} $variant_ar, @param]; | |||||||||||||||||||||||||||||||||||||||||
| 933 | } | ||||||||||||||||||||||||||||||||||||||||||
| 934 | 0 | return choose($variant_ar, $r->headers_in); | |||||||||||||||||||||||||||||||||||||||||
| 935 | |||||||||||||||||||||||||||||||||||||||||||
| 936 | } | ||||||||||||||||||||||||||||||||||||||||||
| 937 | |||||||||||||||||||||||||||||||||||||||||||
| 938 | |||||||||||||||||||||||||||||||||||||||||||
| 939 | 0 | ▶ | sub session { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
session: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 940 | |||||||||||||||||||||||||||||||||||||||||||
| 941 | } | ||||||||||||||||||||||||||||||||||||||||||
| 942 | |||||||||||||||||||||||||||||||||||||||||||
| 943 | 0 | ▶ | sub session_id { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
session_id: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 944 | |||||||||||||||||||||||||||||||||||||||||||
| 945 | } | ||||||||||||||||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||||||||||||||||
| 947 | 0 | ▶ | sub route { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
route: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 948 | |||||||||||||||||||||||||||||||||||||||||||
| 949 | } | ||||||||||||||||||||||||||||||||||||||||||
| 950 | |||||||||||||||||||||||||||||||||||||||||||
| 951 | 0 | ▶ | sub path_parameters { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
path_parameters: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||||||||||||||||
| 953 | } | ||||||||||||||||||||||||||||||||||||||||||
| 954 | |||||||||||||||||||||||||||||||||||||||||||
| 955 | |||||||||||||||||||||||||||||||||||||||||||
| 956 | 0 | ▶ | sub sendfile { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sendfile: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 957 | |||||||||||||||||||||||||||||||||||||||||||
| 958 | } | ||||||||||||||||||||||||||||||||||||||||||
| 959 | |||||||||||||||||||||||||||||||||||||||||||
| 960 | |||||||||||||||||||||||||||||||||||||||||||
| 961 | 0 | ▶ | sub finfo { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
finfo: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 962 | |||||||||||||||||||||||||||||||||||||||||||
| 963 | 0 | return stat(shift->filename()); | |||||||||||||||||||||||||||||||||||||||||
| 964 | |||||||||||||||||||||||||||||||||||||||||||
| 965 | } | ||||||||||||||||||||||||||||||||||||||||||
| 966 | |||||||||||||||||||||||||||||||||||||||||||
| 967 | 0 | ▶ | sub form_parameters { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
form_parameters: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 968 | |||||||||||||||||||||||||||||||||||||||||||
| 969 | } | ||||||||||||||||||||||||||||||||||||||||||
| 970 | |||||||||||||||||||||||||||||||||||||||||||
| 971 | 0 | ▶ | sub id { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
id: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 972 | |||||||||||||||||||||||||||||||||||||||||||
| 973 | } | ||||||||||||||||||||||||||||||||||||||||||
| 974 | |||||||||||||||||||||||||||||||||||||||||||
| 975 | 0 | ▶ | sub multipart_parameters { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
multipart_parameters: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 976 | |||||||||||||||||||||||||||||||||||||||||||
| 977 | } | ||||||||||||||||||||||||||||||||||||||||||
| 978 | |||||||||||||||||||||||||||||||||||||||||||
| 979 | 0 | ▶ | sub query_parameters { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
query_parameters: not called CC=1 SCAR=0.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 980 | |||||||||||||||||||||||||||||||||||||||||||
| 981 | 32 | ▶ | use Hash::MultiValue; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 982 | 0 | return Hash::MultiValue->new(shift()->uri->query_form); | |||||||||||||||||||||||||||||||||||||||||
| 983 | |||||||||||||||||||||||||||||||||||||||||||
| 984 | } | ||||||||||||||||||||||||||||||||||||||||||
| 985 | |||||||||||||||||||||||||||||||||||||||||||
| 986 | 0 | ▶ | sub request_time { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
request_time: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 987 | |||||||||||||||||||||||||||||||||||||||||||
| 988 | } | ||||||||||||||||||||||||||||||||||||||||||
| 989 | |||||||||||||||||||||||||||||||||||||||||||
| 990 | 0 | ▶ | sub scheme { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
scheme: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 991 | |||||||||||||||||||||||||||||||||||||||||||
| 992 | 0 | return 'http', | |||||||||||||||||||||||||||||||||||||||||
| 993 | |||||||||||||||||||||||||||||||||||||||||||
| 994 | } | ||||||||||||||||||||||||||||||||||||||||||
| 995 | |||||||||||||||||||||||||||||||||||||||||||
| 996 | |||||||||||||||||||||||||||||||||||||||||||
| 997 | 0 | ▶ | sub uploads { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uploads: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 998 | |||||||||||||||||||||||||||||||||||||||||||
| 999 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1000 | |||||||||||||||||||||||||||||||||||||||||||
| 1001 | |||||||||||||||||||||||||||||||||||||||||||
| 1002 | # Error handling, autoload | ||||||||||||||||||||||||||||||||||||||||||
| 1003 | |||||||||||||||||||||||||||||||||||||||||||
| 1004 | |||||||||||||||||||||||||||||||||||||||||||
| 1005 | 0 | ▶ | sub err_html { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
err_html: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1006 | |||||||||||||||||||||||||||||||||||||||||||
| 1007 | # Very basic HTML error messages for file not found and similar | ||||||||||||||||||||||||||||||||||||||||||
| 1008 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1009 | 0 | my ($r, $status, $error)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 1010 | 0 | require WebDyne::HTML::Tiny; | |||||||||||||||||||||||||||||||||||||||||
| 1011 | 0 | ▶ | my $html_or=WebDyne::HTML::Tiny->new( mode=>$WEBDYNE_HTML_TINY_MODE, r=>$r ) || | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
'WebDyne::HTML::Tiny'->new('mode', $WebDyne::Request::Fake::WEBDYNE_HTML_TINY_MODE, 'r', $r) || (return err())
MC/DC0%0/1
'WebDyne::HTML::Tiny'->new('mode', $WebDyne::Request::Fake::WEBDYNE_HTML_TINY_MODE, 'r', $r) || (return err())
'WebDyne::HTML::Tiny'->new('mode', $WebDyne::Request::Fake::WEBDYNE_HTML_TINY_MODE, 'r', $r)
Truth table0%0/2
A
A= 'WebDyne::HTML::Tiny'->new('mode', $WebDyne::Request::Fake::WEBDYNE_HTML_TINY_MODE, 'r', $r)
| |||||||||||||||||||||||||||||||||||||||||||
| 1012 | return err(); | ||||||||||||||||||||||||||||||||||||||||||
| 1013 | #my $heading=sprintf("%s error - $error", ref($r) || __PACKAGE__); | ||||||||||||||||||||||||||||||||||||||||||
| 1014 | 0 | ▶ | my $heading=sprintf("%s error.", ref($r) || __PACKAGE__); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
ref $r || __PACKAGE__
MC/DC0%0/1
ref $r || __PACKAGE__
ref $r
Truth table0%0/2
A
A= ref $r
| |||||||||||||||||||||||||||||||||||||||||||
| 1015 | 0 | ▶ | my @body=( | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
&status_message($status) || 'Unknown Error'
MC/DC0%0/1
&status_message($status) || 'Unknown Error'
&status_message($status)
Truth table0%0/2
A
A= &status_message($status)
| |||||||||||||||||||||||||||||||||||||||||||
| 1016 | $html_or->start_html(title=>"WebDyne Error: $status"), | ||||||||||||||||||||||||||||||||||||||||||
| 1017 | $html_or->h3($heading), | ||||||||||||||||||||||||||||||||||||||||||
| 1018 | $html_or->hr(), | ||||||||||||||||||||||||||||||||||||||||||
| 1019 | $html_or->em(status_message($status) || 'Unknown Error'), $html_or->br(), $html_or->br(), | ||||||||||||||||||||||||||||||||||||||||||
| 1020 | $html_or->pre( | ||||||||||||||||||||||||||||||||||||||||||
| 1021 | sprintf("The requested URI '%s' generated error:\n\n$error", $r->uri) | ||||||||||||||||||||||||||||||||||||||||||
| 1022 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 1023 | $html_or->end_html() | ||||||||||||||||||||||||||||||||||||||||||
| 1024 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1025 | 0 | return join('', @body); | |||||||||||||||||||||||||||||||||||||||||
| 1026 | |||||||||||||||||||||||||||||||||||||||||||
| 1027 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1028 | |||||||||||||||||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||||||||||||||||
| 1030 | 0 | ▶ | sub AUTOLOAD { #no subsort | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1031 | |||||||||||||||||||||||||||||||||||||||||||
| 1032 | 0 | my ($r, $v)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 1033 | 0 | 0 && debug("$r AUTOLOAD: $AUTOLOAD, v: $v"); | |||||||||||||||||||||||||||||||||||||||||
| 1034 | 0 | ▶ | my $k=($AUTOLOAD=~/([^:]+)$/) && $1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$WebDyne::Request::Fake::AUTOLOAD =~ /([^:]+)$/ && $1
MC/DC0%0/2
$WebDyne::Request::Fake::AUTOLOAD =~ /([^:]+)$/ && $1
$WebDyne::Request::Fake::AUTOLOAD =~ /([^:]+)$/
$1
Truth table0%0/3
A && B
A= $WebDyne::Request::Fake::AUTOLOAD =~ /([^:]+)$/B= $1
| |||||||||||||||||||||||||||||||||||||||||||
| 1035 | 0 | warn(sprintf("Unhandled '%s' method, using AUTOLOAD. Caller:%s", $k, Dumper([caller(0)]))); | |||||||||||||||||||||||||||||||||||||||||
| 1036 | 0 | ▶ | $v ? $r->{$k}=$v : $r->{$k}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1037 | |||||||||||||||||||||||||||||||||||||||||||
| 1038 | |||||||||||||||||||||||||||||||||||||||||||
| 1039 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1040 | |||||||||||||||||||||||||||||||||||||||||||
| 1041 | |||||||||||||||||||||||||||||||||||||||||||
| 1042 | 739 | ▶ | sub DESTROY { #no subsort | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1043 | |||||||||||||||||||||||||||||||||||||||||||
| 1044 | 739 | my $r=shift(); | |||||||||||||||||||||||||||||||||||||||||
| 1045 | 739 | 0 && debug("$r DESTROY"); | |||||||||||||||||||||||||||||||||||||||||
| 1046 | 739 | ▶ | if (my $cr_ar=delete $r->{'register_cleanup'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1047 | 139 | 0 && debug('found cleanup code refs: %s', Dumper($cr_ar)); | |||||||||||||||||||||||||||||||||||||||||
| 1048 | 139 | foreach my $cr (grep {ref($_) eq 'CODE'} @{$cr_ar}) { | |||||||||||||||||||||||||||||||||||||||||
| 1049 | 139 | 0 && debug("running code ref: $cr against r: $r"); | |||||||||||||||||||||||||||||||||||||||||
| 1050 | 139 | $cr->($r); | |||||||||||||||||||||||||||||||||||||||||
| 1051 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1052 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1053 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1054 | 600 | 0 && debug('no cleanup code registered'); | |||||||||||||||||||||||||||||||||||||||||
| 1055 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1056 | |||||||||||||||||||||||||||||||||||||||||||
| 1057 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1058 | |||||||||||||||||||||||||||||||||||||||||||
| 1059 | __END__ | ||||||||||||||||||||||||||||||||||||||||||