line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Mason::PSGIHandler::Streamy; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$HTML::Mason::PSGIHandler::Streamy::VERSION = '0.53'; |
4
|
|
|
|
|
|
|
} |
5
|
2
|
|
|
2
|
|
76618
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
71
|
|
6
|
2
|
|
|
2
|
|
63
|
use 5.008_001; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
96
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require HTML::Mason::PSGIHandler; # XXX: this is fucked |
9
|
2
|
|
|
2
|
|
13
|
use base qw( HTML::Mason::PSGIHandler ); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1423
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub handle_psgi { |
12
|
12
|
|
|
12
|
0
|
218192
|
my $self = shift; |
13
|
12
|
|
|
|
|
26
|
my $env = shift; |
14
|
|
|
|
|
|
|
|
15
|
12
|
|
|
|
|
85
|
my $p = { |
16
|
|
|
|
|
|
|
comp => $env->{PATH_INFO}, |
17
|
|
|
|
|
|
|
cgi => CGI::PSGI->new($env), |
18
|
|
|
|
|
|
|
}; |
19
|
|
|
|
|
|
|
|
20
|
12
|
|
|
|
|
12985
|
my $r = $self->create_delayed_object('cgi_request', cgi => $p->{cgi}); |
21
|
12
|
|
|
|
|
1094
|
$self->interp->set_global('$r', $r); |
22
|
|
|
|
|
|
|
|
23
|
12
|
|
|
|
|
384
|
my $headers_sent; |
24
|
|
|
|
|
|
|
my $responder; |
25
|
0
|
|
|
|
|
0
|
my $writer; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
$self->interp->out_method( |
28
|
|
|
|
|
|
|
sub { |
29
|
|
|
|
|
|
|
# XXX: the original code from HTTP::Server::Simple::Mason |
30
|
|
|
|
|
|
|
# has the following comment. need to verify memory usage |
31
|
|
|
|
|
|
|
# without the following hack. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# We use instance here because if we store $request we get a |
34
|
|
|
|
|
|
|
# circular reference and a big memory leak. |
35
|
11
|
|
|
11
|
|
5053
|
my $m = HTML::Mason::Request->instance; |
36
|
11
|
|
|
|
|
55
|
my $r = $m->cgi_request; |
37
|
11
|
50
|
|
|
|
55
|
unless ($headers_sent) { |
38
|
11
|
50
|
|
|
|
31
|
die "PANIC: responder not configured yet" unless $responder; |
39
|
11
|
|
|
|
|
41
|
$writer = $responder->([$r->psgi_header()]); |
40
|
11
|
|
|
|
|
2269
|
$headers_sent = 1; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
11
|
|
|
|
|
81
|
$writer->write($_) for @_; |
44
|
12
|
|
|
|
|
39
|
}); |
45
|
|
|
|
|
|
|
|
46
|
12
|
|
|
|
|
805
|
$self->interp->delayed_object_params('request', cgi_request => $r); |
47
|
|
|
|
|
|
|
|
48
|
12
|
|
|
|
|
597
|
my %args = $self->request_args($r); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
return sub { |
51
|
12
|
|
|
12
|
|
252
|
$responder = shift; |
52
|
12
|
|
|
|
|
56
|
my @result = $self->invoke_mason(\%args, $p); |
53
|
12
|
50
|
|
|
|
35
|
die if $@; # XXX: format 500? |
54
|
12
|
100
|
|
|
|
33
|
unless ($writer) { |
55
|
1
|
|
|
|
|
9
|
return $responder->([$r->psgi_header(-Status => $result[0]), []]); |
56
|
|
|
|
|
|
|
} |
57
|
11
|
|
|
|
|
15
|
undef $responder; |
58
|
11
|
|
|
|
|
60
|
$writer->close(); |
59
|
11
|
|
|
|
|
1661
|
undef $writer; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
12
|
|
|
|
|
1488
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |