blib/lib/Net/UPnP/ActionResponse.pm

filter: Statementstmt 76.7% 43 / 56 Branchbran 50.0% 5 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 76.9% 10 / 13 Podpod 25.0% 2 / 8 totaltotal 68.9% 60 / 87 CC 6 SCAR 11.5
CC
6
Cov
73%
getargumentlist
7.0
getstatus
2.0
getheader
2.0
CRAP 3.2
« blib/lib/Net/UPnP/AV/RSS.pm ↑ Summary blib/lib/Net/UPnP/AV/MediaRenderer.pm »
1 package Net::UPnP::ActionResponse;
2  
3 #-----------------------------------------------------------------
4 # Net::UPnP::ActionResponse
5 #-----------------------------------------------------------------
6  
7 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 8 ▶use Net::UPnP::HTTP;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 8 ▶use Net::UPnP::HTTPResponse;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 8 ▶use vars qw($_HTTP_RESPONSE);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 8 $_HTTP_RESPONSE = 'httpres';
16  
17 #------------------------------
18 # new
19 #------------------------------
20  
21 1050 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
22 1050 my($class) = shift;
23 1050 my($this) = {
24 $Net::UPnP::ActionResponse::_HTTP_RESPONSE => undef,
25 };
26 1050 bless $this, $class;
27 }
28  
29 #------------------------------
30 # header
31 #------------------------------
32  
33 1050 ▶sub sethttpresponse() {
Subroutine sethttpresponse: called CC=1 SCAR=0.0
Pod undocumented
34 1050 my($this) = shift;
35 1050 $this->{$Net::UPnP::ActionResponse::_HTTP_RESPONSE} = $_[0];
36 }
37  
38 2089 ▶sub gethttpresponse() {
Subroutine gethttpresponse: called CC=1 SCAR=0.0
Pod undocumented
39 2089 my($this) = shift;
40 2089 $this->{$Net::UPnP::ActionResponse::_HTTP_RESPONSE};
41 }
42
43 #------------------------------
44 # status
45 #------------------------------
46  
47 0 ▶sub getstatus() {
Subroutine getstatus: not called CC=1 SCAR=6.9
Pod undocumented
48 0 my($this) = shift;
49 0 my($http_res) = $this->gethttpresponse();
50 0 $http_res->getstatus();
51 }
52  
53 1051 ▶sub getstatuscode() {
Subroutine getstatuscode: called CC=1 SCAR=0.0
Pod documented
54 1051 my($this) = shift;
55 1051 my($http_res) = $this->gethttpresponse();
56 1051 $http_res->getstatuscode();
57 }
58  
59 #------------------------------
60 # header
61 #------------------------------
62  
63 0 ▶sub getheader() {
Subroutine getheader: not called CC=1 SCAR=6.9
Pod undocumented
64 0 my($this) = shift;
65 0 my($http_res) = $this->gethttpresponse();
66 0 $http_res->getheader();
67 }
68  
69 #------------------------------
70 # content
71 #------------------------------
72  
73 0 ▶sub getcontent() {
Subroutine getcontent: not called CC=1 SCAR=6.9
Pod undocumented
74 0 my($this) = shift;
75 0 my($http_res) = $this->gethttpresponse();
76 0 $http_res->getcontent();
77 }
78  
79 #------------------------------
80 # content
81 #------------------------------
82  
83 1038 ▶sub getargumentlist() {
Subroutine getargumentlist: called CC=6 SCAR=19.4
Pod documented
84 1038 my($this) = shift;
85 my(
86 1038 $http_res,
87 %argument_list,
88 $res_statcode,
89 $res_content,
90 $soap_response,
91 $arg_name,
92 $arg_value,
93 @arg_name_token,
94 );
95
96 1038 %argument_list = ();
97
98 1038 $http_res = $this->gethttpresponse();
99
100 1038 $res_statcode = $http_res->getstatuscode();
101 1038 ▶ if ($res_statcode != 200) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res_statcode != 200) 0 1038 1038
102 0 return \%argument_list;
103 }
104  
105 1038 $res_content = $http_res->getcontent();
106 1038 ▶ if ($res_content =~ m/<.*Response[^>]*>\s*(.*)\s*<\/.*Response>/si) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res_content =~ m[<.*Response[^>]*>\s*(.*)\s*</.*Response>]is) 1038 0 1038
107 1038 $soap_response = $1;
108 }
109
110 1038 ▶ while ($soap_response =~ m/<([^>]*)>([^<]*)<\/[^>]*>/sg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($soap_response =~ m[<([^>]*)>([^<]*)</[^>]*>]gs) 1042 1038 2080
111 1042 $arg_name = $1;
112 1042 ▶ if (0 < index($arg_name, ' ')) {
Branch: 1 branch
BranchTrueFalseTotal
if (0 < index($arg_name, " ")) 0 1042 1042
113 0 @arg_name_token = split(/ /, $arg_name);
114 0 ▶ if (0 < @arg_name_token) {
Branch: 1 branch
BranchTrueFalseTotal
if (0 < @arg_name_token) 0 0 0
115 0 $arg_name = $arg_name_token[0];
116 }
117 }
118 1042 $arg_value = $2;
119 1042 $arg_value = Net::UPnP::HTTP::xmldecode($arg_value);
120 1042 $argument_list{$arg_name} = $arg_value;
121 }
122
123 1038 return \%argument_list;
124 }
125  
126 8 1;
127  
128 __END__
« blib/lib/Net/UPnP/AV/RSS.pm ↑ Summary blib/lib/Net/UPnP/AV/MediaRenderer.pm »