line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::MultiModule::Tasks::HTTPClient; |
2
|
|
|
|
|
|
|
$App::MultiModule::Tasks::HTTPClient::VERSION = '1.161230'; |
3
|
2
|
|
|
2
|
|
986
|
use 5.006; |
|
2
|
|
|
|
|
8
|
|
4
|
2
|
|
|
2
|
|
6
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
612
|
|
5
|
2
|
|
|
2
|
|
6
|
use warnings FATAL => 'all'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
66
|
|
6
|
2
|
|
|
2
|
|
6
|
use POE qw(Component::Client::HTTP); |
|
2
|
|
|
|
|
0
|
|
|
2
|
|
|
|
|
10
|
|
7
|
2
|
|
|
2
|
|
142894
|
use HTTP::Request; |
|
2
|
|
|
|
|
1252
|
|
|
2
|
|
|
|
|
42
|
|
8
|
2
|
|
|
2
|
|
738
|
use Modern::Perl; |
|
2
|
|
|
|
|
2760
|
|
|
2
|
|
|
|
|
8
|
|
9
|
2
|
|
|
2
|
|
218
|
use Data::Dumper; |
|
2
|
|
|
|
|
0
|
|
|
2
|
|
|
|
|
84
|
|
10
|
2
|
|
|
2
|
|
6
|
use Storable; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
70
|
|
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
8
|
use parent 'App::MultiModule::Task'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
12
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
App::MultiModule::Tasks::HTTPClient - Do http/httpds requests in MultiModule |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head2 message |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
23
|
|
|
|
|
|
|
{ |
24
|
|
|
|
|
|
|
sub message { |
25
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
26
|
0
|
|
|
|
|
|
my $message = shift; |
27
|
0
|
|
|
|
|
|
my %args = @_; |
28
|
|
|
|
|
|
|
$self->debug('message', message => $message) |
29
|
0
|
0
|
|
|
|
|
if $self->{debug} > 5; |
30
|
0
|
|
|
|
|
|
my $url = $message->{http_url}; |
31
|
0
|
|
0
|
|
|
|
my $timeout = $message->{http_timeout} || 30; |
32
|
0
|
|
|
|
|
|
POE::Component::Client::HTTP->spawn( |
33
|
|
|
|
|
|
|
Alias => $url, |
34
|
|
|
|
|
|
|
Timeout => $timeout, |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
my $response_handler = sub { |
37
|
0
|
|
|
0
|
|
|
my ($request_packet, $response_packet) = @_[ARG0, ARG1]; |
38
|
0
|
|
|
|
|
|
my $request_object = $request_packet->[0]; |
39
|
0
|
|
|
|
|
|
my $response_object = $response_packet->[0]; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
$message->{http_content} = $response_object->content; |
42
|
0
|
|
|
|
|
|
$message->{http_status_line} = $response_object->status_line; |
43
|
0
|
|
|
|
|
|
$message->{http_code} = $response_object->code; |
44
|
0
|
|
|
|
|
|
$message->{http_is_success} = $response_object->is_success; |
45
|
0
|
|
|
|
|
|
$message->{http_is_info} = $response_object->is_info; |
46
|
0
|
|
|
|
|
|
$message->{http_is_redirect} = $response_object->is_redirect; |
47
|
0
|
|
|
|
|
|
$message->{http_is_error} = $response_object->is_error; |
48
|
0
|
|
|
|
|
|
$message->{http_is_server_error} = $response_object->is_server_error; |
49
|
0
|
|
|
|
|
|
$message->{http_is_client_error} = $response_object->is_client_error; |
50
|
0
|
|
|
|
|
|
$message->{http_is_fresh} = $response_object->is_fresh; |
51
|
0
|
|
|
|
|
|
$message->{http_fresh_until} = $response_object->fresh_until; |
52
|
0
|
|
|
|
|
|
$self->emit($message); |
53
|
0
|
|
|
|
|
|
}; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
POE::Session->create( |
56
|
|
|
|
|
|
|
inline_states => { |
57
|
|
|
|
|
|
|
_start => sub { |
58
|
|
|
|
|
|
|
POE::Kernel->post( |
59
|
|
|
|
|
|
|
$url, # posts to the 'ua' alias |
60
|
|
|
|
|
|
|
'request', # posts to ua's 'request' state |
61
|
|
|
|
|
|
|
'response', # which of our states will receive the response |
62
|
0
|
|
|
0
|
|
|
HTTP::Request->new(GET => $message->{http_url}),# an HTTP::Request object |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
}, |
65
|
|
|
|
0
|
|
|
_stop => sub {}, |
66
|
0
|
|
|
|
|
|
response => $response_handler, |
67
|
|
|
|
|
|
|
}, |
68
|
|
|
|
|
|
|
); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 set_config |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
75
|
|
|
|
|
|
|
sub set_config { |
76
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
77
|
0
|
|
|
|
|
|
my $config = shift; |
78
|
0
|
|
|
|
|
|
$self->{config} = $config; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 AUTHOR |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Dana M. Diederich, C<< <dana@realms.org> >> |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 BUGS |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Please report any bugs or feature requests through L<https://github.com/dana/perl-App-MultiModule-Tasks-HTTPClient/issues>. I will be notified, and then you'll |
89
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 SUPPORT |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
perldoc App::MultiModule::Tasks::HTTPClient |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
You can also look for information at: |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=over 4 |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item * Report bugs here: |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
L<https://github.com/dana/perl-App-MultiModule-Tasks-HTTPClient/issues> |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
L<http://annocpan.org/dist/App-MultiModule-Tasks-HTTPClient> |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item * CPAN Ratings |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
L<http://cpanratings.perl.org/d/App-MultiModule-Tasks-HTTPClient> |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item * Search CPAN |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
L<https://metacpan.org/module/App::MultiModule::Tasks::HTTPClient> |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=back |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Copyright 2016 Dana M. Diederich. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
127
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
128
|
|
|
|
|
|
|
copy of the full license at: |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
L<http://www.perlfoundation.org/artistic_license_2_0> |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified |
133
|
|
|
|
|
|
|
Versions is governed by this Artistic License. By using, modifying or |
134
|
|
|
|
|
|
|
distributing the Package, you accept this license. Do not use, modify, |
135
|
|
|
|
|
|
|
or distribute the Package, if you do not accept this license. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made |
138
|
|
|
|
|
|
|
by someone other than you, you are nevertheless required to ensure that |
139
|
|
|
|
|
|
|
your Modified Version complies with the requirements of this license. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service |
142
|
|
|
|
|
|
|
mark, tradename, or logo of the Copyright Holder. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge |
145
|
|
|
|
|
|
|
patent license to make, have made, use, offer to sell, sell, import and |
146
|
|
|
|
|
|
|
otherwise transfer the Package with respect to any patent claims |
147
|
|
|
|
|
|
|
licensable by the Copyright Holder that are necessarily infringed by the |
148
|
|
|
|
|
|
|
Package. If you institute patent litigation (including a cross-claim or |
149
|
|
|
|
|
|
|
counterclaim) against any party alleging that the Package constitutes |
150
|
|
|
|
|
|
|
direct or contributory patent infringement, then this Artistic License |
151
|
|
|
|
|
|
|
to you shall terminate on the date that such litigation is filed. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER |
154
|
|
|
|
|
|
|
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. |
155
|
|
|
|
|
|
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
156
|
|
|
|
|
|
|
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY |
157
|
|
|
|
|
|
|
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR |
158
|
|
|
|
|
|
|
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR |
159
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, |
160
|
|
|
|
|
|
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=cut |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
1; # End of App::MultiModule::Tasks::HTTPClient |