| 1 | package Net::UPnP::Service; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | #----------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 4 | # Net::Net::UPnP::Service | ||||||||||||||||||||||||||||
| 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; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 8 | ▶ | use Net::UPnP::ActionResponse; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 8 | ▶ | use Net::UPnP::QueryResponse; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 8 | ▶ | use vars qw($_DEVICE $_DEVICE_DESCRIPTION $SERVICETYPE $SERVICEID $SCPDURL $CONTROLURL $EVENTSUBURL); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 8 | $_DEVICE = 'device'; | |||||||||||||||||||||||||||
| 17 | 8 | $_DEVICE_DESCRIPTION = 'device_description'; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 8 | $SERVICETYPE = 'serviceType'; | |||||||||||||||||||||||||||
| 20 | 8 | $SERVICEID = 'serviceId'; | |||||||||||||||||||||||||||
| 21 | 8 | $SCPDURL = 'SCPDURL'; | |||||||||||||||||||||||||||
| 22 | 8 | $CONTROLURL = 'controlURL'; | |||||||||||||||||||||||||||
| 23 | 8 | $EVENTSUBURL = 'eventSubURL'; | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | #------------------------------ | ||||||||||||||||||||||||||||
| 26 | # new | ||||||||||||||||||||||||||||
| 27 | #------------------------------ | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 14 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 30 | 14 | my($class) = shift; | |||||||||||||||||||||||||||
| 31 | 14 | my($this) = { | |||||||||||||||||||||||||||
| 32 | $Net::UPnP::Service::_DEVICE => undef, | ||||||||||||||||||||||||||||
| 33 | $Net::UPnP::Service::_DEVICE_DESCRIPTION => '', | ||||||||||||||||||||||||||||
| 34 | }; | ||||||||||||||||||||||||||||
| 35 | 14 | bless $this, $class; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | #------------------------------ | ||||||||||||||||||||||||||||
| 39 | # device | ||||||||||||||||||||||||||||
| 40 | #------------------------------ | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 14 | ▶ | sub setdevice() { | ||||||||||||||||||||||||||
|
Subroutine
setdevice: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 43 | 14 | my($this) = shift; | |||||||||||||||||||||||||||
| 44 | 14 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 14 | $this->{$Net::UPnP::Service::_DEVICE} = $_[0]; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 34 | ▶ | sub getdevice() { | ||||||||||||||||||||||||||
|
Subroutine
getdevice: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 50 | 34 | my($this) = shift; | |||||||||||||||||||||||||||
| 51 | 34 | $this->{$Net::UPnP::Service::_DEVICE}; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | #------------------------------ | ||||||||||||||||||||||||||||
| 55 | # device description | ||||||||||||||||||||||||||||
| 56 | #------------------------------ | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 16 | ▶ | sub setdevicedescription() { | ||||||||||||||||||||||||||
|
Subroutine
setdevicedescription: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 59 | 16 | my($this) = shift; | |||||||||||||||||||||||||||
| 60 | 16 | $this->{$Net::UPnP::Service::_DEVICE_DESCRIPTION} = $_[0]; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 85 | ▶ | sub getdevicedescription() { | ||||||||||||||||||||||||||
|
Subroutine
getdevicedescription: called CC=3 SCAR=12.3
Pod
documented
| |||||||||||||||||||||||||||||
| 64 | 85 | my($this) = shift; | |||||||||||||||||||||||||||
| 65 | 85 | my %args = ( | |||||||||||||||||||||||||||
| 66 | name => undef, | ||||||||||||||||||||||||||||
| 67 | @_, | ||||||||||||||||||||||||||||
| 68 | ); | ||||||||||||||||||||||||||||
| 69 | 85 | ▶ | if ($args{name}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | 85 | ▶ | unless ($this->{$Net::UPnP::Service::_DEVICE_DESCRIPTION} =~ m/<$args{name}>(.*)<\/$args{name}>/i) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | 0 | return ''; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | 85 | return $1; | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | 0 | $this->{$Net::UPnP::Service::_DEVICE_DESCRIPTION}; | |||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | #------------------------------ | ||||||||||||||||||||||||||||
| 79 | # getservicetype | ||||||||||||||||||||||||||||
| 80 | #------------------------------ | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 66 | ▶ | sub getservicetype() { | ||||||||||||||||||||||||||
|
Subroutine
getservicetype: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 83 | 66 | my($this) = shift; | |||||||||||||||||||||||||||
| 84 | 66 | $this->getdevicedescription(name => $Net::UPnP::Service::SERVICETYPE); | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | #------------------------------ | ||||||||||||||||||||||||||||
| 88 | # getserviceid | ||||||||||||||||||||||||||||
| 89 | #------------------------------ | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 0 | ▶ | sub getserviceid() { | ||||||||||||||||||||||||||
|
Subroutine
getserviceid: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 92 | 0 | my($this) = shift; | |||||||||||||||||||||||||||
| 93 | 0 | $this->getdevicedescription(name => $Net::UPnP::Service::SERVICEID); | |||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | #------------------------------ | ||||||||||||||||||||||||||||
| 97 | # getscpdurl | ||||||||||||||||||||||||||||
| 98 | #------------------------------ | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 0 | ▶ | sub getscpdurl() { | ||||||||||||||||||||||||||
|
Subroutine
getscpdurl: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 101 | 0 | my($this) = shift; | |||||||||||||||||||||||||||
| 102 | 0 | $this->getdevicedescription(name => $Net::UPnP::Service::SCPDURL); | |||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | #------------------------------ | ||||||||||||||||||||||||||||
| 106 | # getcontrolurl | ||||||||||||||||||||||||||||
| 107 | #------------------------------ | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 19 | ▶ | sub getcontrolurl() { | ||||||||||||||||||||||||||
|
Subroutine
getcontrolurl: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 110 | 19 | my($this) = shift; | |||||||||||||||||||||||||||
| 111 | 19 | $this->getdevicedescription(name => $Net::UPnP::Service::CONTROLURL); | |||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | #------------------------------ | ||||||||||||||||||||||||||||
| 115 | # geteventsuburl | ||||||||||||||||||||||||||||
| 116 | #------------------------------ | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 0 | ▶ | sub geteventsuburl() { | ||||||||||||||||||||||||||
|
Subroutine
geteventsuburl: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 119 | 0 | my($this) = shift; | |||||||||||||||||||||||||||
| 120 | 0 | $this->getdevicedescription(name => $Net::UPnP::Service::EVENTSUBURL); | |||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | #------------------------------ | ||||||||||||||||||||||||||||
| 124 | # getposturl | ||||||||||||||||||||||||||||
| 125 | #------------------------------ | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 22 | ▶ | sub getposturl() { | ||||||||||||||||||||||||||
|
Subroutine
getposturl: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 128 | 22 | my($this) = shift; | |||||||||||||||||||||||||||
| 129 | 22 | my ($ctrl_url) = @_; | |||||||||||||||||||||||||||
| 130 | my ( | ||||||||||||||||||||||||||||
| 131 | 22 | $dev, | |||||||||||||||||||||||||||
| 132 | $location_url, | ||||||||||||||||||||||||||||
| 133 | $url_base, | ||||||||||||||||||||||||||||
| 134 | ); | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 22 | $dev = $this->getdevice(); | |||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | 22 | $location_url = $dev->getlocation(); | |||||||||||||||||||||||||||
| 139 | 22 | $url_base = $dev->geturlbase(); | |||||||||||||||||||||||||||
| 140 | # Use the caller's URL when given; fall back to the service's | ||||||||||||||||||||||||||||
| 141 | # controlURL only when none is supplied (RT #21076). | ||||||||||||||||||||||||||||
| 142 | 22 | ▶ | $ctrl_url = $this->getcontrolurl() unless defined($ctrl_url) && length($ctrl_url); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $ctrl_url and length $ctrl_url
MC/DC100%2/2
defined $ctrl_url and length $ctrl_url
defined $ctrl_url
length $ctrl_url
Truth table100%3/3
A and B
A= defined $ctrl_urlB= length $ctrl_url
| |||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | #print "$location_url\n"; | ||||||||||||||||||||||||||||
| 145 | #print "$url_base\n"; | ||||||||||||||||||||||||||||
| 146 | #print "$ctrl_url\n"; | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | 22 | ▶ | unless ($ctrl_url =~ m{http://(.*)}i) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 149 | 17 | ▶ | if (0 < length($url_base)) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 150 | # Thanks for Thus0 (2005/01/12) | ||||||||||||||||||||||||||||
| 151 | 6 | $ctrl_url = _joinurl($url_base, $ctrl_url); | |||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||
| 153 | elsif ($location_url =~ m{http://([0-9a-z.-]+)(?::(\d+))?(?:/|\z)}i) { | ||||||||||||||||||||||||||||
| 154 | # A relative controlURL is resolved against the host of the | ||||||||||||||||||||||||||||
| 155 | # description URL, always separated by exactly one "/" | ||||||||||||||||||||||||||||
| 156 | # (RT #21076). | ||||||||||||||||||||||||||||
| 157 | 11 | ▶ | my $port = $2 || 80; | ||||||||||||||||||||||||||
|
Condition100%2/2
$2 || 80
MC/DC100%1/1
$2 || 80
$2
Truth table100%2/2
A
A= $2
| |||||||||||||||||||||||||||||
| 158 | 11 | $ctrl_url = _joinurl('http://' . $1 . ':' . $port, $ctrl_url); | |||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||
| 160 | else { | ||||||||||||||||||||||||||||
| 161 | 0 | $ctrl_url = _joinurl($location_url, $ctrl_url); | |||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 22 | return $ctrl_url; | |||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 17 | ▶ | sub _joinurl { | ||||||||||||||||||||||||||
|
Subroutine
_joinurl: called CC=7 SCAR=20.2
| |||||||||||||||||||||||||||||
| 169 | 17 | my ($base, $path) = @_; | |||||||||||||||||||||||||||
| 170 | 17 | ▶ | return $base unless defined($path) && length($path); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $path and length $path
MC/DC0%0/2
defined $path and length $path
defined $path
length $path
Truth table33%1/3
A and B
A= defined $pathB= length $path
| |||||||||||||||||||||||||||||
| 171 | 17 | my $base_slash = substr($base, -1) eq '/'; | |||||||||||||||||||||||||||
| 172 | 17 | my $path_slash = index($path, '/') == 0; | |||||||||||||||||||||||||||
| 173 | 17 | ▶ | return $base . substr($path, 1) if $base_slash && $path_slash; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$base_slash and $path_slash
MC/DC50%1/2
$base_slash and $path_slash
$base_slash
$path_slash
Truth table66%2/3
A and B
A= $base_slashB= $path_slash
| |||||||||||||||||||||||||||||
| 174 | 12 | ▶ | return $base . $path if $base_slash || $path_slash; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$base_slash or $path_slash
MC/DC50%1/2
$base_slash or $path_slash
$base_slash
$path_slash
Truth table66%2/3
A or B
A= $base_slashB= $path_slash
| |||||||||||||||||||||||||||||
| 175 | 4 | return $base . '/' . $path; | |||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | #------------------------------ | ||||||||||||||||||||||||||||
| 179 | # postaction | ||||||||||||||||||||||||||||
| 180 | #------------------------------ | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | 9 | ▶ | sub postaction() { | ||||||||||||||||||||||||||
|
Subroutine
postaction: called CC=10 SCAR=24.9
Pod
documented
| |||||||||||||||||||||||||||||
| 183 | 9 | my($this) = shift; | |||||||||||||||||||||||||||
| 184 | 9 | my ($action_name, $action_arg, $http_options) = @_; | |||||||||||||||||||||||||||
| 185 | my ( | ||||||||||||||||||||||||||||
| 186 | 9 | $dev, | |||||||||||||||||||||||||||
| 187 | $ctrl_url, | ||||||||||||||||||||||||||||
| 188 | $service_type, | ||||||||||||||||||||||||||||
| 189 | $soap_action, | ||||||||||||||||||||||||||||
| 190 | $soap_content, | ||||||||||||||||||||||||||||
| 191 | $arg_name, | ||||||||||||||||||||||||||||
| 192 | $arg_value, | ||||||||||||||||||||||||||||
| 193 | $post_addr, | ||||||||||||||||||||||||||||
| 194 | $post_port, | ||||||||||||||||||||||||||||
| 195 | $post_path, | ||||||||||||||||||||||||||||
| 196 | $http_req, | ||||||||||||||||||||||||||||
| 197 | $post_res, | ||||||||||||||||||||||||||||
| 198 | $action_res, | ||||||||||||||||||||||||||||
| 199 | $key, | ||||||||||||||||||||||||||||
| 200 | ); | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | 9 | $action_res = Net::UPnP::ActionResponse->new(); | |||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | 9 | $dev = $this->getdevice(); | |||||||||||||||||||||||||||
| 205 | 9 | $ctrl_url = $this->getcontrolurl(); | |||||||||||||||||||||||||||
| 206 | 9 | $ctrl_url = $this->getposturl($ctrl_url); | |||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 9 | ▶ | unless ($ctrl_url =~ m{http://([0-9a-z.-]+)(?::(\d+))?/(.*)}i) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 209 | #print "Invalid URL : $ctrl_url\n"; | ||||||||||||||||||||||||||||
| 210 | 0 | $post_res = Net::UPnP::HTTPResponse->new(); | |||||||||||||||||||||||||||
| 211 | 0 | $action_res->sethttpresponse($post_res); | |||||||||||||||||||||||||||
| 212 | 0 | return $action_res; | |||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||
| 214 | 9 | $post_addr = $1; | |||||||||||||||||||||||||||
| 215 | 9 | ▶ | $post_port = $2 || 80; | ||||||||||||||||||||||||||
|
Condition100%2/2
$2 || 80
MC/DC100%1/1
$2 || 80
$2
Truth table100%2/2
A
A= $2
| |||||||||||||||||||||||||||||
| 216 | 9 | ▶ | if (index($3, '/') == 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 217 | 0 | $post_path = $3; | |||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | else { | ||||||||||||||||||||||||||||
| 220 | 9 | $post_path = '/' . $3; | |||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | 9 | $service_type = $this->getservicetype(); | |||||||||||||||||||||||||||
| 224 | 9 | $soap_action = '"' . $service_type . '#' . $action_name . '"'; | |||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | 9 | $soap_content = <<"SOAP_CONTENT"; | |||||||||||||||||||||||||||
| 228 | <?xml version=\"1.0\" encoding=\"utf-8\"?> | ||||||||||||||||||||||||||||
| 229 | <s:Envelope xmlns:s=\"http:\/\/schemas.xmlsoap.org\/soap\/envelope\/\" s:encodingStyle=\"http:\/\/schemas.xmlsoap.org\/soap\/encoding/\"> | ||||||||||||||||||||||||||||
| 230 | \t<s:Body> | ||||||||||||||||||||||||||||
| 231 | \t\t<u:$action_name xmlns:u=\"$service_type\"> | ||||||||||||||||||||||||||||
| 232 | SOAP_CONTENT | ||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | 9 | ▶ | if (ref $action_arg) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 235 | 9 | ▶ | while (($arg_name, $arg_value) = each (%{$action_arg} ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 236 | 0 | ▶ | if (length($arg_value) <= 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 237 | 0 | $soap_content .= "\t\t\t<$arg_name \/>\n"; | |||||||||||||||||||||||||||
| 238 | 0 | next; | |||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||
| 240 | 0 | $soap_content .= "\t\t\t<$arg_name>$arg_value<\/$arg_name>\n"; | |||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | 9 | $soap_content .= <<"SOAP_CONTENT"; | |||||||||||||||||||||||||||
| 245 | \t\t</u:$action_name> | ||||||||||||||||||||||||||||
| 246 | \t</s:Body> | ||||||||||||||||||||||||||||
| 247 | </s:Envelope> | ||||||||||||||||||||||||||||
| 248 | SOAP_CONTENT | ||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | 9 | ▶ | my %options = %{$http_options || {}}; | ||||||||||||||||||||||||||
|
Condition100%2/2
$http_options || {}
MC/DC100%1/1
$http_options || {}
$http_options
Truth table100%2/2
A
A= $http_options
| |||||||||||||||||||||||||||||
| 251 | 9 | my $allowed = $dev->getallowedaddresses(); | |||||||||||||||||||||||||||
| 252 | 9 | ▶ | $options{allowed_addresses} = $allowed if defined $allowed; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 253 | 9 | $http_req = Net::UPnP::HTTP->new(%options); | |||||||||||||||||||||||||||
| 254 | 9 | $post_res = $http_req->postsoap($post_addr, $post_port, $post_path, $soap_action, $soap_content); | |||||||||||||||||||||||||||
| 255 | 9 | ▶ | $post_res ||= Net::UPnP::HTTPResponse->new(); | ||||||||||||||||||||||||||
|
Condition66%2/3
$post_res ||= "Net::UPnP::HTTPResponse"->new
MC/DC0%0/2
$post_res ||= "Net::UPnP::HTTPResponse"->new
$post_res
"Net::UPnP::HTTPResponse"->new
Truth table66%2/3
A ||= B
A= $post_resB= "Net::UPnP::HTTPResponse"->new
| |||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | 9 | $action_res->sethttpresponse($post_res); | |||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | 9 | return $action_res; | |||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | #------------------------------ | ||||||||||||||||||||||||||||
| 263 | # postcontrol | ||||||||||||||||||||||||||||
| 264 | #------------------------------ | ||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | 3 | ▶ | sub postcontrol() { | ||||||||||||||||||||||||||
|
Subroutine
postcontrol: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 267 | 3 | my($this) = shift; | |||||||||||||||||||||||||||
| 268 | 3 | return $this->postaction(@_); | |||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | #------------------------------ | ||||||||||||||||||||||||||||
| 272 | # postquery | ||||||||||||||||||||||||||||
| 273 | #------------------------------ | ||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | 3 | ▶ | sub postquery() { | ||||||||||||||||||||||||||
|
Subroutine
postquery: called CC=7 SCAR=20.3
Pod
documented
| |||||||||||||||||||||||||||||
| 276 | 3 | my($this) = shift; | |||||||||||||||||||||||||||
| 277 | 3 | my ($var_name) = @_; | |||||||||||||||||||||||||||
| 278 | my ( | ||||||||||||||||||||||||||||
| 279 | 3 | $dev, | |||||||||||||||||||||||||||
| 280 | $ctrl_url, | ||||||||||||||||||||||||||||
| 281 | $service_type, | ||||||||||||||||||||||||||||
| 282 | $soap_action, | ||||||||||||||||||||||||||||
| 283 | $soap_content, | ||||||||||||||||||||||||||||
| 284 | $post_addr, | ||||||||||||||||||||||||||||
| 285 | $post_port, | ||||||||||||||||||||||||||||
| 286 | $post_path, | ||||||||||||||||||||||||||||
| 287 | $http_req, | ||||||||||||||||||||||||||||
| 288 | $post_res, | ||||||||||||||||||||||||||||
| 289 | $query_res, | ||||||||||||||||||||||||||||
| 290 | ); | ||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | 3 | $query_res = Net::UPnP::QueryResponse->new(); | |||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | 3 | $dev = $this->getdevice(); | |||||||||||||||||||||||||||
| 295 | 3 | $ctrl_url = $this->getcontrolurl(); | |||||||||||||||||||||||||||
| 296 | 3 | $ctrl_url = $this->getposturl($ctrl_url); | |||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | 3 | ▶ | print "ctrl_url=$ctrl_url\n" if ($Net::UPnP::DEBUG); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 299 | 3 | ▶ | unless ($ctrl_url =~ m{http://([0-9a-z.-]+)(?::(\d+))?/(.*)}i) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 300 | 0 | $post_res = Net::UPnP::HTTPResponse->new(); | |||||||||||||||||||||||||||
| 301 | 0 | $query_res->sethttpresponse($post_res); | |||||||||||||||||||||||||||
| 302 | 0 | return $query_res; | |||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||
| 304 | 3 | $post_addr = $1; | |||||||||||||||||||||||||||
| 305 | 3 | ▶ | $post_port = $2 || 80; | ||||||||||||||||||||||||||
|
Condition100%2/2
$2 || 80
MC/DC100%1/1
$2 || 80
$2
Truth table100%2/2
A
A= $2
| |||||||||||||||||||||||||||||
| 306 | 3 | ▶ | if (index($3, '/') == 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 307 | 0 | $post_path = $3; | |||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||
| 309 | else { | ||||||||||||||||||||||||||||
| 310 | 3 | $post_path = '/' . $3; | |||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||
| 312 | 3 | $service_type = $this->getservicetype(); | |||||||||||||||||||||||||||
| 313 | 3 | $soap_action = '"urn:schemas-upnp-org:control-1-0#QueryStateVariable"'; | |||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | 3 | $soap_content = <<"SOAP_CONTENT"; | |||||||||||||||||||||||||||
| 317 | <?xml version=\"1.0\" encoding=\"utf-8\"?> | ||||||||||||||||||||||||||||
| 318 | <s:Envelope xmlns:s=\"http:\/\/schemas.xmlsoap.org\/soap\/envelope\/\" s:encodingStyle=\"http:\/\/schemas.xmlsoap.org\/soap\/encoding/\"> | ||||||||||||||||||||||||||||
| 319 | \t<s:Body> | ||||||||||||||||||||||||||||
| 320 | \t\t<u:QueryStateVariable xmlns:u=\"urn:schemas-upnp-org:control-1-0\"> | ||||||||||||||||||||||||||||
| 321 | \t\t\t<u:varName>$var_name</u:varName> | ||||||||||||||||||||||||||||
| 322 | \t\t</u:QueryStateVariable> | ||||||||||||||||||||||||||||
| 323 | \t</s:Body> | ||||||||||||||||||||||||||||
| 324 | </s:Envelope> | ||||||||||||||||||||||||||||
| 325 | SOAP_CONTENT | ||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||
| 327 | 3 | my $allowed = $dev->getallowedaddresses(); | |||||||||||||||||||||||||||
| 328 | 3 | ▶ | $http_req = Net::UPnP::HTTP->new(defined($allowed) ? (allowed_addresses => $allowed) : ()); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 329 | 3 | $post_res = $http_req->postsoap($post_addr, $post_port, $post_path, $soap_action, $soap_content); | |||||||||||||||||||||||||||
| 330 | 3 | ▶ | $post_res ||= Net::UPnP::HTTPResponse->new(); | ||||||||||||||||||||||||||
|
Condition33%1/3
$post_res ||= "Net::UPnP::HTTPResponse"->new
MC/DC0%0/2
$post_res ||= "Net::UPnP::HTTPResponse"->new
$post_res
"Net::UPnP::HTTPResponse"->new
Truth table33%1/3
A ||= B
A= $post_resB= "Net::UPnP::HTTPResponse"->new
| |||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | 3 | $query_res->sethttpresponse($post_res); | |||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | 3 | return $query_res; | |||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | 8 | 1; | |||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | __END__ | ||||||||||||||||||||||||||||