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
|
|
1233
|
use strict; |
|
3
|
|
|
|
|
18
|
|
|
3
|
|
|
|
|
79
|
|
11
|
3
|
|
|
3
|
|
12
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
66
|
|
12
|
|
|
|
|
|
|
|
13
|
3
|
|
|
3
|
|
1250
|
use cPanel::APIClient::Utils::JSON (); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
53
|
|
14
|
3
|
|
|
3
|
|
1102
|
use cPanel::APIClient::X (); |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
587
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub get_http_method { |
17
|
7
|
|
|
7
|
0
|
19
|
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
|
19
|
my ( $self, $resp_obj, $resp_body ) = @_; |
26
|
|
|
|
|
|
|
|
27
|
5
|
100
|
|
|
|
21
|
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
|
|
|
|
|
21
|
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
|
|
|
|
|
27
|
die cPanel::APIClient::X->create( 'SubTransport', $description ); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _EXTRACT_RESPONSE { |
45
|
4
|
|
|
4
|
|
38
|
return $_[1]; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |