line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::App::WWW; |
2
|
2
|
|
|
2
|
|
74578
|
use strict; |
|
2
|
|
|
|
|
16
|
|
|
2
|
|
|
|
|
62
|
|
3
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
80
|
|
4
|
2
|
|
|
2
|
|
603
|
use parent qw/Plack::App::CGIBin/; |
|
2
|
|
|
|
|
331
|
|
|
2
|
|
|
|
|
10
|
|
5
|
2
|
|
|
2
|
|
167092
|
use Plack::App::File; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
56
|
|
6
|
2
|
|
|
2
|
|
14
|
use Plack::App::WrapCGI; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
35
|
|
7
|
2
|
|
|
2
|
|
1205
|
use Plack::App::Directory; |
|
2
|
|
|
|
|
119405
|
|
|
2
|
|
|
|
|
875
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub call { |
12
|
3
|
|
|
3
|
1
|
21918
|
my $self = shift; |
13
|
3
|
|
|
|
|
7
|
my $env = shift; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# check if path info is a folder, if true add directory index |
16
|
|
|
|
|
|
|
return Plack::App::Directory->new( |
17
|
|
|
|
|
|
|
root => $self->root |
18
|
3
|
50
|
|
|
|
15
|
)->to_app->($env) if -d $self->root . $env->{PATH_INFO}; |
19
|
|
|
|
|
|
|
|
20
|
3
|
|
|
|
|
159
|
my ($file, $path_info) = $self->locate_file($env); |
21
|
3
|
50
|
|
|
|
265
|
return $file if ref $file eq 'ARRAY'; |
22
|
|
|
|
|
|
|
|
23
|
3
|
50
|
|
|
|
10
|
if ($path_info) { |
24
|
0
|
|
|
|
|
0
|
$env->{'plack.file.SCRIPT_NAME'} = $env->{SCRIPT_NAME} . $env->{PATH_INFO}; |
25
|
0
|
|
|
|
|
0
|
$env->{'plack.file.SCRIPT_NAME'} =~ s/\Q$path_info\E$//; |
26
|
0
|
|
|
|
|
0
|
$env->{'plack.file.PATH_INFO'} = $path_info; |
27
|
|
|
|
|
|
|
} else { |
28
|
3
|
|
|
|
|
11
|
$env->{'plack.file.SCRIPT_NAME'} = $env->{SCRIPT_NAME} . $env->{PATH_INFO}; |
29
|
3
|
|
|
|
|
7
|
$env->{'plack.file.PATH_INFO'} = ''; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
3
|
|
|
|
|
9
|
return $self->serve_path($env, $file); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub serve_path { |
36
|
3
|
|
|
3
|
0
|
7
|
my($self, $env, $file) = @_; |
37
|
|
|
|
|
|
|
|
38
|
3
|
|
|
|
|
5
|
local @{$env}{qw(SCRIPT_NAME PATH_INFO)} = @{$env}{qw( plack.file.SCRIPT_NAME plack.file.PATH_INFO )}; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
6
|
|
39
|
|
|
|
|
|
|
|
40
|
3
|
100
|
|
|
|
8
|
if ($self->_valid_file_perl($file)) { |
41
|
2
|
|
33
|
|
|
22
|
my $app = $self->{_compiled}->{$file} ||= Plack::App::WrapCGI->new( |
42
|
|
|
|
|
|
|
script => $file, execute => $self->would_exec($file) |
43
|
|
|
|
|
|
|
)->to_app; |
44
|
2
|
|
|
|
|
1781
|
$app->($env); |
45
|
|
|
|
|
|
|
} else { |
46
|
1
|
|
|
|
|
14
|
Plack::App::File->new(file => $file)->to_app->($env); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub _valid_file_perl { |
51
|
3
|
|
|
3
|
|
15
|
my ($self, $file) = @_; |
52
|
|
|
|
|
|
|
|
53
|
3
|
100
|
|
|
|
24
|
return 1 if $file =~ /.(pl|cgi)$/i; |
54
|
1
|
50
|
|
|
|
5
|
return 1 if $self->shebang_for($file) =~ /^\#\!.*perl/; |
55
|
|
|
|
|
|
|
|
56
|
1
|
|
|
|
|
79
|
return; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |