| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package POE::Component::Client::HTTPDeferred::Deferred; |
|
2
|
2
|
|
|
2
|
|
309152
|
use Any::Moose; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
16
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
1129
|
use POE; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
has request => ( |
|
7
|
|
|
|
|
|
|
is => 'rw', |
|
8
|
|
|
|
|
|
|
isa => 'HTTP::Request', |
|
9
|
|
|
|
|
|
|
weak_ref => 1, |
|
10
|
|
|
|
|
|
|
required => 1, |
|
11
|
|
|
|
|
|
|
); |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has client_alias => ( |
|
14
|
|
|
|
|
|
|
is => 'rw', |
|
15
|
|
|
|
|
|
|
isa => 'Str', |
|
16
|
|
|
|
|
|
|
required => 1, |
|
17
|
|
|
|
|
|
|
); |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has callbacks => ( |
|
20
|
|
|
|
|
|
|
is => 'rw', |
|
21
|
|
|
|
|
|
|
isa => 'ArrayRef', |
|
22
|
|
|
|
|
|
|
lazy => 1, |
|
23
|
|
|
|
|
|
|
default => sub { [] }, |
|
24
|
|
|
|
|
|
|
); |
|
25
|
|
|
|
|
|
|
|
|
26
|
2
|
|
|
2
|
|
736
|
no Any::Moose; |
|
|
2
|
|
|
|
|
10
|
|
|
|
2
|
|
|
|
|
9
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 NAME |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
POE::Component::Client::HTTPDeferred::Deferred - Deferred class for POE::Component::Client::HTTPDeferred. |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
L. |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 METHOD |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 new |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $d = POE::Component::Client::HTTPDeferred::Deferred->new; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Create deferred object. |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 cancel |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
$d->cancel; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Cancel HTTP Request. |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub cancel { |
|
53
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
54
|
0
|
|
|
|
|
0
|
$poe_kernel->post( $self->client_alias => cancel => $self->request ); |
|
55
|
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
0
|
$self; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 callback |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
$d->callback($response); |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
An normal response callback method. This is called when http request is successful. |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub callback { |
|
68
|
0
|
|
|
0
|
1
|
0
|
my ($self, $res) = @_; |
|
69
|
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
0
|
for my $cb (@{ $self->callbacks }) { |
|
|
0
|
|
|
|
|
0
|
|
|
71
|
0
|
0
|
|
|
|
0
|
$cb->[0]->($res) if $cb->[0]; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 errback |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
$d->errback($response); |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
An error response callback. This is called when http request is failed. |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub errback { |
|
84
|
1
|
|
|
1
|
1
|
8
|
my ($self, $res) = @_; |
|
85
|
|
|
|
|
|
|
|
|
86
|
1
|
|
|
|
|
2
|
for my $cb (@{ $self->callbacks }) { |
|
|
1
|
|
|
|
|
14
|
|
|
87
|
1
|
50
|
|
|
|
19
|
$cb->[1]->($res) if $cb->[1]; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 addBoth |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
$d->addBoth($callback); |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Add $callback to both callback and errback. |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
This is same as following: |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
$d->addCallbacks($callback, $callback); |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub addBoth { |
|
104
|
1
|
|
|
1
|
1
|
21
|
my ($self, $cb) = @_; |
|
105
|
1
|
|
|
|
|
7
|
$self->addCallbacks($cb, $cb); |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 addCallback |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
$d->addCallback($callback); |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Add $callback to normal callback. |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub addCallback { |
|
117
|
0
|
|
|
0
|
1
|
0
|
my ($self, $cb) = @_; |
|
118
|
0
|
|
|
|
|
0
|
$self->addCallbacks($cb, undef); |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 addCallbacks |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
$d->addCallbacks( $callback, $errback ); |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Add $callback to normal callback, and $errback to error callback. |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=cut |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub addCallbacks { |
|
130
|
1
|
|
|
1
|
1
|
2
|
my ($self, $cb, $eb) = @_; |
|
131
|
1
|
|
|
|
|
3
|
push @{ $self->callbacks }, [ $cb, $eb ]; |
|
|
1
|
|
|
|
|
10
|
|
|
132
|
|
|
|
|
|
|
|
|
133
|
1
|
|
|
|
|
8
|
$self; |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head2 addErrback |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
$d->addErrback( $errback ); |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Add $errback to error callback. |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=cut |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub addErrback { |
|
145
|
0
|
|
|
0
|
1
|
|
my ($self, $eb) = @_; |
|
146
|
0
|
|
|
|
|
|
$self->addCallbacks(undef, $eb); |
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 AUTHOR |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Daisuke Murase |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
This program is free software; you can redistribute |
|
156
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
The full text of the license can be found in the |
|
159
|
|
|
|
|
|
|
LICENSE file included with this module. |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=cut |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |