line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Mason::PSGIHandler; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$HTML::Mason::PSGIHandler::VERSION = '0.53'; |
4
|
|
|
|
|
|
|
} |
5
|
3
|
|
|
3
|
|
103707
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
100
|
|
6
|
3
|
|
|
3
|
|
66
|
use 5.008_001; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
129
|
|
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
19
|
use base qw( HTML::Mason::CGIHandler ); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
6280
|
|
9
|
3
|
|
|
3
|
|
668133
|
use CGI::PSGI; |
|
3
|
|
|
|
|
8465
|
|
|
3
|
|
|
|
|
34
|
|
10
|
3
|
|
|
3
|
|
196
|
use HTML::Mason::Exceptions; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
31
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
4
|
|
|
4
|
1
|
64
|
my $class = shift; |
14
|
4
|
|
|
|
|
55
|
$class->SUPER::new( |
15
|
|
|
|
|
|
|
request_class => 'HTML::Mason::Request::PSGI', |
16
|
|
|
|
|
|
|
@_, |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub as_psgi { |
21
|
2
|
|
|
2
|
0
|
43762
|
my $self = shift; |
22
|
2
|
|
|
4
|
|
16
|
return sub { $self->handle_psgi( $_[0] ) }; |
|
4
|
|
|
|
|
11181
|
|
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub new_psgi { |
26
|
1
|
|
|
1
|
1
|
3
|
my $class = shift; |
27
|
1
|
|
|
|
|
5
|
$class->new(@_)->as_psgi; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub handle_psgi { |
31
|
6
|
|
|
6
|
0
|
109491
|
my $self = shift; |
32
|
6
|
|
|
|
|
16
|
my $env = shift; |
33
|
|
|
|
|
|
|
|
34
|
6
|
|
|
|
|
55
|
my $p = { |
35
|
|
|
|
|
|
|
comp => $env->{PATH_INFO}, |
36
|
|
|
|
|
|
|
cgi => CGI::PSGI->new($env), |
37
|
|
|
|
|
|
|
}; |
38
|
|
|
|
|
|
|
|
39
|
6
|
|
|
|
|
9965
|
my $r = $self->create_delayed_object('cgi_request', cgi => $p->{cgi}); |
40
|
6
|
|
|
|
|
717
|
$self->interp->set_global('$r', $r); |
41
|
|
|
|
|
|
|
|
42
|
6
|
|
|
|
|
238
|
my $output; |
43
|
6
|
|
|
|
|
22
|
$self->interp->out_method( \$output ); |
44
|
6
|
|
|
|
|
492
|
$self->interp->delayed_object_params('request', cgi_request => $r); |
45
|
|
|
|
|
|
|
|
46
|
6
|
|
|
|
|
327
|
my %args = $self->request_args($r); |
47
|
|
|
|
|
|
|
|
48
|
6
|
|
|
|
|
917
|
my @result = $self->invoke_mason(\%args, $p); |
49
|
6
|
50
|
|
|
|
44
|
die if $@; |
50
|
|
|
|
|
|
|
|
51
|
6
|
100
|
|
|
|
35
|
return [ $r->psgi_header(-Status => $result[0]), [ defined $output ? $output : () ] ]; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub invoke_mason { |
55
|
18
|
|
|
18
|
0
|
30
|
my ($self, $args, $p) = @_; |
56
|
|
|
|
|
|
|
|
57
|
18
|
|
|
|
|
25
|
my @result; |
58
|
18
|
50
|
|
|
|
88
|
if (wantarray) { |
|
|
0
|
|
|
|
|
|
59
|
18
|
|
|
|
|
25
|
@result = eval { $self->interp->exec($p->{comp}, %$args) }; |
|
18
|
|
|
|
|
59
|
|
60
|
|
|
|
|
|
|
} elsif ( defined wantarray ) { |
61
|
0
|
|
|
|
|
0
|
$result[0] = eval { $self->interp->exec($p->{comp}, %$args) }; |
|
0
|
|
|
|
|
0
|
|
62
|
|
|
|
|
|
|
} else { |
63
|
0
|
|
|
|
|
0
|
eval { $self->interp->exec($p->{comp}, %$args) }; |
|
0
|
|
|
|
|
0
|
|
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
18
|
|
|
|
|
259
|
return @result; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub HTML::Mason::FakeApache::psgi_header { |
70
|
18
|
|
|
18
|
0
|
29
|
my $self = shift; |
71
|
18
|
|
|
|
|
71
|
my $h = $self->headers_out; |
72
|
18
|
|
|
|
|
2471
|
my $e = $self->err_headers_out; |
73
|
|
|
|
|
|
|
|
74
|
18
|
|
|
|
|
3575
|
my %args = (tied(%$h)->cgi_headers, tied(%$e)->cgi_headers, @_); |
75
|
18
|
50
|
|
|
|
227
|
if (exists $h->{Location}) { |
76
|
0
|
|
|
|
|
0
|
%args = (%args, -Status => 302); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
18
|
|
|
|
|
285
|
return $self->query->psgi_header(%args); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
package HTML::Mason::Request::PSGI; |
83
|
|
|
|
|
|
|
{ |
84
|
|
|
|
|
|
|
$HTML::Mason::Request::PSGI::VERSION = '0.53'; |
85
|
|
|
|
|
|
|
} |
86
|
3
|
|
|
3
|
|
2196
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
108
|
|
87
|
3
|
|
|
3
|
|
77
|
use base qw(HTML::Mason::Request::CGI); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
2447
|
|
88
|
|
|
|
|
|
|
|
89
|
3
|
|
|
3
|
|
108
|
use HTML::Mason::Exceptions; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
16
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub exec { |
92
|
18
|
|
|
18
|
|
21393
|
my $self = shift; |
93
|
18
|
|
|
|
|
77
|
my $r = $self->cgi_request; |
94
|
18
|
|
|
|
|
73
|
my $retval; |
95
|
|
|
|
|
|
|
|
96
|
18
|
|
|
|
|
28
|
eval { $retval = $self->HTML::Mason::Request::exec(@_) }; |
|
18
|
|
|
|
|
98
|
|
97
|
|
|
|
|
|
|
|
98
|
18
|
50
|
|
|
|
11012
|
if (my $err = $@) { |
99
|
0
|
0
|
|
|
|
0
|
$retval = isa_mason_exception($err, 'Abort') ? $err->aborted_value |
|
|
0
|
|
|
|
|
|
100
|
|
|
|
|
|
|
: isa_mason_exception($err, 'Decline') ? $err->declined_value |
101
|
|
|
|
|
|
|
: rethrow_exception $err; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
18
|
|
|
|
|
75
|
return $retval; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
package HTML::Mason::PSGIHandler; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
1; |
110
|
|
|
|
|
|
|
__END__ |