| 1 | # | ||||||||||||||||||||||||||||
| 2 | # Copyright (c) 2018 cPanel, L.L.C. | ||||||||||||||||||||||||||||
| 3 | # All rights reserved. | ||||||||||||||||||||||||||||
| 4 | # http://cpanel.net/ | ||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||
| 6 | # Distributed under the terms of the MIT license. See the LICENSE file for | ||||||||||||||||||||||||||||
| 7 | # further details. | ||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||
| 9 | package OpenStack::Client::Response; | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use base 'HTTP::Response'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | sub decode_json { | ||||||||||||||||||||||||||||
| 17 | 50 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
decode_json: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 50 | my $type = $self->header('Content-Type'); | |||||||||||||||||||||||||||
| 20 | 50 | my $content = $self->decoded_content; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 50 | ▶ | if ($self->code =~ /^[45]\d{2}$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | 3 | ▶ | $content ||= "@{[$self->code]} Unknown error"; | ||||||||||||||||||||||||||
|
Condition100%2/2
$content ||= "@{[$self->code];} Unknown error"
MC/DC100%1/1
$content ||= "@{[$self->code];} Unknown error"
$content
Truth table100%2/2
A
A= $content
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 3 | die $content; | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 47 | ▶ | if (defined $content && length $content) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $content and length $content
MC/DC50%1/2
defined $content and length $content
defined $content
length $content
Truth table66%2/3
A and B
A= defined $contentB= length $content
| |||||||||||||||||||||||||||||
| 29 | 38 | ▶ | if (lc($type) =~ qr{^application/json}i) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | 37 | return JSON::decode_json($content); | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 10 | return $content; | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 2 | 1; | |||||||||||||||||||||||||||