| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Eixo::Rest::Client; |
|
2
|
3
|
|
|
3
|
|
1004185
|
use strict; |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
84
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
3
|
|
|
3
|
|
457
|
use Eixo::Base::Clase; |
|
|
3
|
|
|
|
|
7368
|
|
|
|
3
|
|
|
|
|
17
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
1476
|
use URI; |
|
|
3
|
|
|
|
|
9566
|
|
|
|
3
|
|
|
|
|
93
|
|
|
7
|
3
|
|
|
3
|
|
1646
|
use LWP::UserAgent; |
|
|
3
|
|
|
|
|
76059
|
|
|
|
3
|
|
|
|
|
82
|
|
|
8
|
3
|
|
|
3
|
|
1114
|
use LWP::Protocol::https; |
|
|
3
|
|
|
|
|
122051
|
|
|
|
3
|
|
|
|
|
101
|
|
|
9
|
3
|
|
|
3
|
|
567
|
use JSON -convert_blessed_universally; |
|
|
3
|
|
|
|
|
7139
|
|
|
|
3
|
|
|
|
|
47
|
|
|
10
|
3
|
|
|
3
|
|
713
|
use Carp; |
|
|
3
|
|
|
|
|
3
|
|
|
|
3
|
|
|
|
|
145
|
|
|
11
|
3
|
|
|
3
|
|
12
|
use Data::Dumper; |
|
|
3
|
|
|
|
|
3
|
|
|
|
3
|
|
|
|
|
150
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
3
|
|
|
3
|
|
13
|
use Config; |
|
|
3
|
|
|
|
|
3
|
|
|
|
3
|
|
|
|
|
129
|
|
|
14
|
3
|
|
|
3
|
|
1210
|
use Eixo::Rest::RequestSync; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
22
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $REQ_PARSER = qr/\:\:([a-z]+)([A-Z]\w+?)$/; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $USER_AGENT_VERSION = 'EixoAgent/0.1'; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has( |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
ua=>undef, |
|
25
|
|
|
|
|
|
|
endpoint=>undef, |
|
26
|
|
|
|
|
|
|
format=>'json', |
|
27
|
|
|
|
|
|
|
error_callback => undef, |
|
28
|
|
|
|
|
|
|
current_method => undef, |
|
29
|
|
|
|
|
|
|
); |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub initialize{ |
|
32
|
3
|
|
|
3
|
0
|
2015
|
my ($self, $endpoint, %opts) = @_; |
|
33
|
|
|
|
|
|
|
|
|
34
|
3
|
|
|
|
|
28
|
$self->endpoint($endpoint); |
|
35
|
|
|
|
|
|
|
|
|
36
|
3
|
50
|
|
|
|
22
|
die("API ENDPOINT NEEDED") unless($self->endpoint); |
|
37
|
|
|
|
|
|
|
|
|
38
|
3
|
|
|
|
|
60
|
$self->ua($USER_AGENT_VERSION, %opts); |
|
39
|
|
|
|
|
|
|
|
|
40
|
3
|
|
|
|
|
6
|
$self; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub ua { |
|
44
|
10
|
|
|
10
|
0
|
724
|
my ($self, $ua_str, %opts) = @_; |
|
45
|
|
|
|
|
|
|
|
|
46
|
10
|
100
|
|
|
|
55
|
if($ua_str){ |
|
47
|
3
|
|
|
|
|
107
|
my $ua = LWP::UserAgent->new(%opts); |
|
48
|
3
|
|
|
|
|
7406
|
$ua->agent($ua_str); |
|
49
|
3
|
|
|
|
|
116
|
$self->{ua} = $ua; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
10
|
|
|
|
|
36
|
return $self->{ua}; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub AUTOLOAD{ |
|
58
|
8
|
|
|
8
|
|
1413
|
my ($self, %args) = @_; |
|
59
|
|
|
|
|
|
|
|
|
60
|
8
|
|
|
|
|
75
|
my ($method, $entity) = our $AUTOLOAD =~ $REQ_PARSER; |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# store current method for tracing |
|
63
|
8
|
|
|
|
|
29
|
$self->current_method($method.$entity); |
|
64
|
|
|
|
|
|
|
|
|
65
|
8
|
|
|
|
|
44
|
$entity = lc($entity); |
|
66
|
|
|
|
|
|
|
|
|
67
|
8
|
100
|
|
|
|
18
|
unless(grep { $method eq $_ } qw(put get post delete patch)){ |
|
|
40
|
|
|
|
|
68
|
|
|
68
|
1
|
|
|
|
|
278
|
confess(ref($self) . ': UNKNOW METHOD: ' . $method); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
7
|
|
|
|
|
10
|
my ($id, $action); |
|
72
|
|
|
|
|
|
|
|
|
73
|
7
|
100
|
|
|
|
16
|
if(exists($args{id})){ |
|
74
|
1
|
|
|
|
|
2
|
$id = $args{id}; |
|
75
|
1
|
|
|
|
|
2
|
delete($args{id}); |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
7
|
100
|
|
|
|
21
|
if(exists($args{action})){ |
|
79
|
2
|
|
|
|
|
3
|
$action = $args{action}; |
|
80
|
2
|
|
|
|
|
3
|
delete($args{action}); |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
7
|
50
|
|
|
|
23
|
if($args{__job_id}){ |
|
84
|
0
|
|
|
|
|
0
|
$args{'__client_send_method'} = '__sendAsync'; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
else{ |
|
87
|
7
|
|
|
|
|
15
|
$args{'__client_send_method'} = '__send'; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
7
|
100
|
|
|
|
14
|
if(!$args{__format}){ |
|
91
|
5
|
|
|
|
|
17
|
$args{__format} = $self->format; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# set error_callback unless already established |
|
95
|
7
|
50
|
|
|
|
40
|
unless(defined($args{PROCESS_DATA}->{onError})){ |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
$args{PROCESS_DATA}->{onError} = sub { |
|
98
|
|
|
|
|
|
|
|
|
99
|
0
|
|
|
0
|
|
0
|
$self->remote_error(@_); |
|
100
|
|
|
|
|
|
|
|
|
101
|
7
|
|
|
|
|
25
|
}; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
7
|
|
|
|
|
8
|
my $uri; |
|
105
|
|
|
|
|
|
|
|
|
106
|
7
|
100
|
|
|
|
19
|
if($uri = $args{uri}) { |
|
107
|
2
|
|
|
|
|
7
|
$uri = $self->build_predefined_uri($uri); |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
else{ |
|
110
|
5
|
|
|
|
|
33
|
$uri = $self->build_uri($entity, $id, $action, $args{__implicit_format}); |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
7
|
|
|
|
|
20078
|
$self->$method($uri, %args); |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
0
|
|
|
sub DESTROY {} |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub head: Log { |
|
120
|
0
|
|
|
0
|
0
|
0
|
my ($self, $uri, %args) = @_; |
|
121
|
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
0
|
$uri->query_form($args{GET_DATA}); |
|
123
|
|
|
|
|
|
|
|
|
124
|
0
|
|
|
|
|
0
|
my $req = HTTP::Request->new(GET => $uri); |
|
125
|
|
|
|
|
|
|
|
|
126
|
0
|
|
0
|
|
|
0
|
$self->set_headers($req, $args{HEADER_DATA} || {}); |
|
127
|
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
0
|
my $send_method = $args{__client_send_method}; |
|
129
|
|
|
|
|
|
|
|
|
130
|
0
|
|
|
|
|
0
|
$self->$send_method($req, %args); |
|
131
|
3
|
|
|
3
|
|
1335
|
} |
|
|
3
|
|
|
|
|
3
|
|
|
|
3
|
|
|
|
|
39
|
|
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub get: Log { |
|
134
|
|
|
|
|
|
|
|
|
135
|
5
|
|
|
3
|
0
|
55
|
my ($self, $uri, %args) = @_; |
|
136
|
|
|
|
|
|
|
|
|
137
|
5
|
|
|
|
|
34
|
$uri->query_form($args{GET_DATA}); |
|
138
|
|
|
|
|
|
|
|
|
139
|
5
|
|
|
|
|
389
|
my $req = HTTP::Request->new(GET => $uri); |
|
140
|
|
|
|
|
|
|
|
|
141
|
5
|
|
50
|
|
|
453
|
$self->set_headers($req, $args{HEADER_DATA} || {}); |
|
142
|
|
|
|
|
|
|
|
|
143
|
5
|
|
|
|
|
13
|
my $send_method = $args{__client_send_method}; |
|
144
|
|
|
|
|
|
|
|
|
145
|
5
|
|
|
|
|
40
|
$self->__encode_request_body($req,%args); |
|
146
|
|
|
|
|
|
|
|
|
147
|
5
|
|
|
|
|
65
|
$self->$send_method($req, %args); |
|
148
|
3
|
|
|
3
|
|
754
|
} |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
9
|
|
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub post: Log { |
|
151
|
2
|
|
|
2
|
0
|
8
|
my ($self,$uri,%args) = @_; |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
# Is possible to add query string args to post requests |
|
154
|
2
|
|
|
|
|
7
|
$uri->query_form($args{GET_DATA}); |
|
155
|
|
|
|
|
|
|
|
|
156
|
2
|
|
|
|
|
64
|
my $req = HTTP::Request->new(POST => $uri); |
|
157
|
|
|
|
|
|
|
|
|
158
|
2
|
|
50
|
|
|
88
|
$self->set_headers($req, $args{HEADER_DATA} || {}); |
|
159
|
|
|
|
|
|
|
|
|
160
|
2
|
|
|
|
|
4
|
my $send_method = $args{__client_send_method}; |
|
161
|
|
|
|
|
|
|
|
|
162
|
2
|
|
|
|
|
7
|
$self->__encode_request_body($req,%args); |
|
163
|
|
|
|
|
|
|
|
|
164
|
2
|
|
|
|
|
31
|
$self->$send_method($req, %args); |
|
165
|
3
|
|
|
3
|
|
608
|
} |
|
|
3
|
|
|
|
|
3
|
|
|
|
3
|
|
|
|
|
8
|
|
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub delete: Log { |
|
168
|
|
|
|
|
|
|
|
|
169
|
0
|
|
|
0
|
0
|
0
|
my ($self, $uri, %args) = @_; |
|
170
|
|
|
|
|
|
|
|
|
171
|
0
|
|
|
|
|
0
|
$uri->query_form($args{GET_DATA}); |
|
172
|
|
|
|
|
|
|
|
|
173
|
0
|
|
|
|
|
0
|
my $req = HTTP::Request->new(DELETE => $uri); |
|
174
|
|
|
|
|
|
|
|
|
175
|
0
|
|
0
|
|
|
0
|
$self->set_headers($req, $args{HEADER_DATA} || {}); |
|
176
|
|
|
|
|
|
|
|
|
177
|
0
|
|
|
|
|
0
|
my $send_method = $args{__client_send_method}; |
|
178
|
|
|
|
|
|
|
|
|
179
|
0
|
|
|
|
|
0
|
$self->__encode_request_body($req,%args); |
|
180
|
|
|
|
|
|
|
|
|
181
|
0
|
|
|
|
|
0
|
$self->$send_method($req, %args); |
|
182
|
3
|
|
|
3
|
|
546
|
} |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
8
|
|
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
sub patch: Log { |
|
185
|
0
|
|
|
0
|
0
|
0
|
my ($self, $uri, %args) = @_; |
|
186
|
|
|
|
|
|
|
|
|
187
|
0
|
|
|
|
|
0
|
$uri->query_form($args{GET_DATA}); |
|
188
|
|
|
|
|
|
|
|
|
189
|
0
|
|
|
|
|
0
|
my $req = HTTP::Request->new(PATCH => $uri); |
|
190
|
|
|
|
|
|
|
|
|
191
|
0
|
|
0
|
|
|
0
|
$self->set_headers($req, $args{HEADER_DATA} || {}); |
|
192
|
|
|
|
|
|
|
|
|
193
|
0
|
|
|
|
|
0
|
my $send_method = $args{__client_send_method}; |
|
194
|
|
|
|
|
|
|
|
|
195
|
0
|
|
|
|
|
0
|
$self->__encode_request_body($req,%args); |
|
196
|
|
|
|
|
|
|
|
|
197
|
0
|
|
|
|
|
0
|
$self->$send_method($req, %args); |
|
198
|
|
|
|
|
|
|
|
|
199
|
3
|
|
|
3
|
|
568
|
} |
|
|
3
|
|
|
|
|
3
|
|
|
|
3
|
|
|
|
|
8
|
|
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
sub put: Log { |
|
202
|
0
|
|
|
0
|
0
|
0
|
my ($self, $uri, %args) = @_; |
|
203
|
|
|
|
|
|
|
|
|
204
|
0
|
|
|
|
|
0
|
$uri->query_form($args{GET_DATA}); |
|
205
|
|
|
|
|
|
|
|
|
206
|
0
|
|
|
|
|
0
|
my $req = HTTP::Request->new(PUT=> $uri); |
|
207
|
|
|
|
|
|
|
|
|
208
|
0
|
|
0
|
|
|
0
|
$self->set_headers($req, $args{HEADER_DATA} || {}); |
|
209
|
|
|
|
|
|
|
|
|
210
|
0
|
|
|
|
|
0
|
my $send_method = $args{__client_send_method}; |
|
211
|
|
|
|
|
|
|
|
|
212
|
0
|
|
|
|
|
0
|
$self->__encode_request_body($req,%args); |
|
213
|
|
|
|
|
|
|
|
|
214
|
0
|
|
|
|
|
0
|
$self->$send_method($req, %args); |
|
215
|
3
|
|
|
3
|
|
541
|
} |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
8
|
|
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
sub __encode_request_body{ |
|
219
|
7
|
|
|
7
|
|
19
|
my ($self,$req, %args) = @_; |
|
220
|
|
|
|
|
|
|
|
|
221
|
7
|
100
|
|
|
|
20
|
return unless($args{POST_DATA}); |
|
222
|
|
|
|
|
|
|
|
|
223
|
4
|
|
|
|
|
4
|
my $content; |
|
224
|
4
|
|
50
|
|
|
16
|
my $content_type = $req->header('Content-Type') |
|
225
|
|
|
|
|
|
|
|| 'application/json'; |
|
226
|
|
|
|
|
|
|
#|| 'application/x-www-form-urlencoded'; |
|
227
|
|
|
|
|
|
|
|
|
228
|
4
|
50
|
|
|
|
167
|
if($content_type eq "application/json"){ |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
$content = JSON->new->allow_blessed(1) |
|
231
|
|
|
|
|
|
|
->convert_blessed(1)#->utf8 |
|
232
|
4
|
|
50
|
|
|
107
|
->encode($args{POST_DATA} || {}); |
|
233
|
|
|
|
|
|
|
} |
|
234
|
|
|
|
|
|
|
else{ |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
# application/x-www-form-urlencoded |
|
237
|
|
|
|
|
|
|
# raw stream |
|
238
|
0
|
0
|
|
|
|
0
|
while(my ($key, $value) = each (%{$args{POST_DATA} || {}})){ |
|
|
0
|
|
|
|
|
0
|
|
|
239
|
0
|
|
|
|
|
0
|
$content .= "$key=$value&"; |
|
240
|
|
|
|
|
|
|
} |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
} |
|
243
|
|
|
|
|
|
|
|
|
244
|
4
|
|
|
|
|
26
|
$req->header("Content-Type", "$content_type; charset=utf-8"); |
|
245
|
4
|
50
|
|
|
|
137
|
$req->add_content_utf8($content) if($content); |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
} |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
sub build_uri { |
|
251
|
5
|
|
|
5
|
0
|
13
|
my ($self, $entity, $id,$action, $implicit_format) = @_; |
|
252
|
|
|
|
|
|
|
|
|
253
|
5
|
|
|
|
|
12
|
my $uri = $self->{endpoint}.'/'.$entity; |
|
254
|
|
|
|
|
|
|
|
|
255
|
5
|
100
|
|
|
|
12
|
$uri .= '/'.$id if(defined($id)); |
|
256
|
5
|
100
|
|
|
|
12
|
$uri .= '/'.$action if(defined($action)); |
|
257
|
|
|
|
|
|
|
|
|
258
|
5
|
100
|
|
|
|
29
|
return URI->new($uri) if($implicit_format); |
|
259
|
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
($self->current_method =~ /^get/)? |
|
261
|
|
|
|
|
|
|
|
|
262
|
3
|
100
|
|
|
|
6
|
URI->new($uri.'/'.$self->{format}) : |
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
URI->new($uri); |
|
265
|
|
|
|
|
|
|
} |
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
sub build_predefined_uri{ |
|
268
|
2
|
|
|
2
|
0
|
5
|
my ($self, $uri) = @_; |
|
269
|
|
|
|
|
|
|
|
|
270
|
2
|
|
|
|
|
4
|
my $endpoint = $self->{endpoint}; |
|
271
|
|
|
|
|
|
|
|
|
272
|
2
|
50
|
|
|
|
13
|
$endpoint .= "/" unless($endpoint =~ /\/$/); |
|
273
|
|
|
|
|
|
|
|
|
274
|
2
|
|
|
|
|
6
|
$uri =~ s/^\///; |
|
275
|
|
|
|
|
|
|
|
|
276
|
2
|
|
|
|
|
12
|
return URI->new($endpoint . $uri) |
|
277
|
|
|
|
|
|
|
} |
|
278
|
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
sub generate_query_str { |
|
281
|
0
|
|
|
0
|
0
|
0
|
my ($self, %args) = @_; |
|
282
|
|
|
|
|
|
|
|
|
283
|
0
|
|
|
|
|
0
|
join '&', map {"$_=$args{$_}"} keys(%args); |
|
|
0
|
|
|
|
|
0
|
|
|
284
|
|
|
|
|
|
|
} |
|
285
|
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
sub __send{ |
|
288
|
7
|
|
|
7
|
|
17
|
my ($self, $req, %args) = @_; |
|
289
|
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
Eixo::Rest::RequestSync->new( |
|
291
|
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
callback=>$args{__callback}, |
|
293
|
|
|
|
|
|
|
|
|
294
|
7
|
|
|
|
|
74
|
%{$args{PROCESS_DATA}}, |
|
295
|
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
__format=>$args{__format} |
|
297
|
|
|
|
|
|
|
|
|
298
|
7
|
|
|
|
|
10
|
)->send( |
|
299
|
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
$self->ua(), |
|
301
|
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
$req |
|
303
|
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
); |
|
305
|
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
} |
|
307
|
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
sub __sendAsync{ |
|
309
|
0
|
|
|
0
|
|
0
|
my ($self, $req, %args) = @_; |
|
310
|
|
|
|
|
|
|
|
|
311
|
0
|
0
|
|
|
|
0
|
die("unsupported: ERROR: This Perl not built to support threads\n") if (! $Config{'useithreads'}); |
|
312
|
|
|
|
|
|
|
|
|
313
|
0
|
|
|
|
|
0
|
eval 'use Eixo::Rest::RequestAsync'; |
|
314
|
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
Eixo::Rest::RequestAsync->new( |
|
316
|
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
job_id=>$args{__job_id}, |
|
318
|
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
api=>$args{api}, |
|
320
|
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
callback=>$args{__callback}, |
|
322
|
|
|
|
|
|
|
|
|
323
|
0
|
|
|
|
|
0
|
%{$args{PROCESS_DATA}}, |
|
324
|
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
__format=>$args{__format} |
|
326
|
|
|
|
|
|
|
|
|
327
|
0
|
|
|
|
|
0
|
)->send( |
|
328
|
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
$self->ua(), |
|
330
|
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
$req |
|
332
|
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
); |
|
334
|
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
} |
|
336
|
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
sub remote_error { |
|
338
|
0
|
|
|
0
|
0
|
0
|
my ($self,$response) = @_; |
|
339
|
|
|
|
|
|
|
|
|
340
|
0
|
|
|
|
|
0
|
my $status = $response->code; |
|
341
|
0
|
|
|
|
|
0
|
my $extra = $response->content; |
|
342
|
|
|
|
|
|
|
|
|
343
|
0
|
0
|
|
|
|
0
|
if(defined($self->error_callback)){ |
|
344
|
|
|
|
|
|
|
|
|
345
|
0
|
|
|
|
|
0
|
&{$self->error_callback}( |
|
|
0
|
|
|
|
|
0
|
|
|
346
|
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
$self->current_method, |
|
348
|
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
'ERROR_CODE', |
|
350
|
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
$status, |
|
352
|
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
$extra, |
|
354
|
|
|
|
|
|
|
#@extra_args |
|
355
|
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
); |
|
357
|
|
|
|
|
|
|
} |
|
358
|
|
|
|
|
|
|
else{ |
|
359
|
0
|
|
|
|
|
0
|
die "Remote Api error: ($status). Details: $extra\n"; |
|
360
|
|
|
|
|
|
|
} |
|
361
|
|
|
|
|
|
|
} |
|
362
|
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
sub set_headers{ |
|
364
|
7
|
|
|
7
|
0
|
14
|
my ($self, $req, $headers) = @_; |
|
365
|
|
|
|
|
|
|
|
|
366
|
7
|
|
|
|
|
20
|
$req->header($_, $headers->{$_}) foreach(keys %$headers); |
|
367
|
|
|
|
|
|
|
} |
|
368
|
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
1; |