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
|
3
|
|
|
3
|
|
1355
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
88
|
|
11
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
68
|
|
12
|
|
|
|
|
|
|
|
13
|
3
|
|
|
3
|
|
1310
|
use cPanel::APIClient::Utils::JSON (); |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
58
|
|
14
|
3
|
|
|
3
|
|
1159
|
use cPanel::APIClient::X (); |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
607
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub get_http_method { |
17
|
7
|
|
|
7
|
0
|
18
|
return 'POST'; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub get_http_headers { |
21
|
7
|
|
|
7
|
0
|
27
|
return [ 'Content-Type' => 'application/x-www-form-urlencoded' ]; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub parse_http_response { |
25
|
5
|
|
|
5
|
0
|
21
|
my ( $self, $resp_obj, $resp_body ) = @_; |
26
|
|
|
|
|
|
|
|
27
|
5
|
100
|
|
|
|
25
|
if ( $resp_obj->code() !~ m<\A2> ) { |
28
|
1
|
|
|
|
|
5
|
die cPanel::APIClient::X->create( 'HTTP', $resp_obj->as_string() . $/ . $resp_body ); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
4
|
|
|
|
|
27
|
my $resp_struct = cPanel::APIClient::Utils::JSON::decode($resp_body); |
32
|
|
|
|
|
|
|
|
33
|
4
|
|
|
|
|
25
|
return $self->HTTP_RESPONSE_CLASS()->new( |
34
|
|
|
|
|
|
|
$self->_EXTRACT_RESPONSE($resp_struct), |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub create_transport_error { |
39
|
2
|
|
|
2
|
0
|
8
|
my ( $self, $description, @properties_kv ) = @_; |
40
|
|
|
|
|
|
|
|
41
|
2
|
|
|
|
|
18
|
die cPanel::APIClient::X->create( 'SubTransport', $description ); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _EXTRACT_RESPONSE { |
45
|
4
|
|
|
4
|
|
42
|
return $_[1]; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |