line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
use strict; |
2
|
3
|
|
|
3
|
|
511
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
87
|
|
3
|
3
|
|
|
3
|
|
15
|
use utf8; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
71
|
|
4
|
3
|
|
|
3
|
|
587
|
use Carp (); |
|
3
|
|
|
|
|
20
|
|
|
3
|
|
|
|
|
13
|
|
5
|
3
|
|
|
3
|
|
68
|
use HTTP::Headers (); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
39
|
|
6
|
3
|
|
|
3
|
|
1668
|
|
|
3
|
|
|
|
|
7462
|
|
|
3
|
|
|
|
|
1160
|
|
7
|
|
|
|
|
|
|
my $class = shift; |
8
|
|
|
|
|
|
|
my %args = @_ == 1 ? %{$_[0]} : @_; |
9
|
4
|
|
|
4
|
0
|
3223
|
$args{code} || Carp::croak "Missing mandatory parameter: code"; |
10
|
4
|
50
|
|
|
|
18
|
bless { |
|
0
|
|
|
|
|
0
|
|
11
|
4
|
50
|
|
|
|
25
|
headers => HTTP::Headers->new, |
12
|
4
|
|
|
|
|
18
|
%args |
13
|
|
|
|
|
|
|
}, $class; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
my $self = shift; |
16
|
|
|
|
|
|
|
$self->headers->header(@_); |
17
|
|
|
|
|
|
|
} |
18
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
19
|
0
|
|
|
|
|
0
|
delete $self->{headers}; |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
0
|
0
|
0
|
# Defence from HTTP Header Splitting. |
22
|
|
|
|
|
|
|
my $code = delete $self->{code}; |
23
|
4
|
|
|
4
|
0
|
53
|
return sub { |
24
|
4
|
|
|
|
|
32
|
my $responder = shift; |
25
|
|
|
|
|
|
|
$code->( |
26
|
|
|
|
|
|
|
sub { |
27
|
4
|
|
|
|
|
10
|
my @copy = @{ $_[0]->[1] }; |
28
|
|
|
|
|
|
|
while (my (undef, $val) = splice(@copy, 0, 2)) { |
29
|
4
|
|
|
4
|
|
29
|
if ($val =~ /[\000-\037]/) { |
30
|
|
|
|
|
|
|
die("Response headers MUST NOT contain characters below octal \037\n"); |
31
|
|
|
|
|
|
|
} |
32
|
4
|
|
|
|
|
24
|
} |
|
4
|
|
|
|
|
19
|
|
33
|
4
|
|
|
|
|
19
|
return $responder->(@_); |
34
|
5
|
100
|
|
|
|
31
|
} |
35
|
3
|
|
|
|
|
21
|
); |
36
|
|
|
|
|
|
|
}; |
37
|
|
|
|
|
|
|
} |
38
|
1
|
|
|
|
|
4
|
|
39
|
|
|
|
|
|
|
|
40
|
4
|
|
|
|
|
31
|
1; |
41
|
4
|
|
|
|
|
30
|
|
42
|
|
|
|
|
|
|
=head1 NAME |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Amon2::Web::Response::Callback - [EXPERIMENTAL]callback style psgi response for Amon2 |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 SYNOPSIS |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
use Amon2::Lite; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
any '/cb' => sub { |
51
|
|
|
|
|
|
|
my $c = shift; |
52
|
|
|
|
|
|
|
Amon2::Web::Response::Callback->new( |
53
|
|
|
|
|
|
|
code => sub { |
54
|
|
|
|
|
|
|
my $respond = shift; |
55
|
|
|
|
|
|
|
$respond->([200, [], []]); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
}; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 DESCRIPTION |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
This module provides a response object for delayed response/streaming body. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
You can embed the AE support, streaming support, etc on Amon2 with this module. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 SEE ALSO |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
L<Tatsumaki> |
69
|
|
|
|
|
|
|
|