File Coverage

blib/lib/cPanel/APIClient/Utils/HTTPResponse.pm
Criterion Covered Total %
statement 6 21 28.5
branch 0 2 0.0
condition n/a
subroutine 2 6 33.3
pod 0 4 0.0
total 8 33 24.2


line stmt bran cond sub pod time code
1             package cPanel::APIClient::Utils::HTTPResponse;
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 2     2   13 use strict;
  2         4  
  2         55  
11 2     2   10 use warnings;
  2         14  
  2         703  
12              
13             # Right now these are the only pieces of HTTP::Response that we need.
14             # HTTP::Response is fairly large, so since we only need a small part of it,
15             # we implement those parts ourselves.
16              
17             sub new {
18 0     0 0   my ( $class, $code, $resp_head, $resp_body ) = @_;
19              
20 0           return bless [ $code, $resp_head, $resp_body ], $class;
21             }
22              
23             sub code {
24 0     0 0   my ($self) = @_;
25              
26 0           return $self->[0];
27             }
28              
29             sub as_string {
30 0     0 0   my ($self) = @_;
31              
32 0           return $self->[1] . $self->[2];
33             }
34              
35             # needed for sessions
36             sub header {
37 0     0 0   my ( $self, $name ) = @_;
38              
39 0           $name =~ tr;
40              
41 0           my @lines = split m<\x0d?\x0a>, $self->[1];
42              
43 0           for my $line (@lines) {
44 0           my ( $thisname, $value ) = split m<\s*:\s*>, $line;
45 0           $thisname =~ tr;
46              
47 0 0         if ( $name eq $thisname ) {
48 0           return $value;
49             }
50             }
51              
52 0           return undef;
53             }
54              
55             1;