line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package cPanel::APIClient::Request::HTTPBase; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Copyright 2020 cPanel, L. L. C. |
4
|
|
|
|
|
|
|
# All rights reserved. |
5
|
|
|
|
|
|
|
# http://cpanel.net |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under the |
8
|
|
|
|
|
|
|
# same terms as Perl itself. See L. |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
448
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
11
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
416
|
use cPanel::APIClient::Utils::JSON (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
14
|
1
|
|
|
1
|
|
391
|
use cPanel::APIClient::X (); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
202
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub get_http_method { |
17
|
0
|
|
|
0
|
0
|
|
return 'POST'; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub get_http_headers { |
21
|
0
|
|
|
0
|
0
|
|
return [ 'Content-Type' => 'application/x-www-form-urlencoded' ]; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub parse_http_response { |
25
|
0
|
|
|
0
|
0
|
|
my ( $self, $resp_obj, $resp_body ) = @_; |
26
|
|
|
|
|
|
|
|
27
|
0
|
0
|
|
|
|
|
if ( $resp_obj->code() !~ m<\A2> ) { |
28
|
0
|
|
|
|
|
|
die cPanel::APIClient::X->create( 'HTTP', $resp_obj->as_string() . $/ . $resp_body ); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
my $resp_struct = cPanel::APIClient::Utils::JSON::decode($resp_body); |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
return $self->HTTP_RESPONSE_CLASS()->new( |
34
|
|
|
|
|
|
|
$self->_EXTRACT_RESPONSE($resp_struct), |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub create_transport_error { |
39
|
0
|
|
|
0
|
0
|
|
my ( $self, $description, @properties_kv ) = @_; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
die cPanel::APIClient::X->create( 'SubTransport', $description ); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _EXTRACT_RESPONSE { |
45
|
0
|
|
|
0
|
|
|
return $_[1]; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |