| 1 | package Twilio::Base::BaseClient; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 20 | ▶ | use 5.016; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 20 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 20 | ▶ | use POSIX (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 20 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 20 | ▶ | use Twilio; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 20 | ▶ | use Twilio::Exceptions::ConfigurationException; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 20 | ▶ | use Twilio::Exceptions::TwilioException; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 20 | ▶ | use Twilio::Http::TinyClient; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 20 | our $VERSION = '2.001'; | |||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 20 | my $ENV_ACCOUNT_SID = 'TWILIO_ACCOUNT_SID'; | |||||||||||||||||||||||||||||||||||||||||
| 17 | 20 | my $ENV_AUTH_TOKEN = 'TWILIO_AUTH_TOKEN'; | |||||||||||||||||||||||||||||||||||||||||
| 18 | 20 | my $ENV_REGION = 'TWILIO_REGION'; | |||||||||||||||||||||||||||||||||||||||||
| 19 | 20 | my $ENV_EDGE = 'TWILIO_EDGE'; | |||||||||||||||||||||||||||||||||||||||||
| 20 | 20 | my $ENV_LOG_LEVEL = 'TWILIO_LOG_LEVEL'; | |||||||||||||||||||||||||||||||||||||||||
| 21 | 20 | my $DEFAULT_REGION = 'us1'; | |||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 20 | my $PIECES_WITH_REGION = 4; # product.region.twilio.com | |||||||||||||||||||||||||||||||||||||||||
| 24 | 20 | my $PIECES_WITH_EDGE = 5; # product.edge.region.twilio.com | |||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 20 | my $STATUS_TOO_MANY_REQUESTS = 429; | |||||||||||||||||||||||||||||||||||||||||
| 27 | 20 | my $RETRY_BACKOFF_BASE = 2; | |||||||||||||||||||||||||||||||||||||||||
| 28 | 20 | my $RETRY_MAX_WAIT_SECONDS = 60; | |||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 1939 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 1939 | my ($class, $username, $password, $options) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 32 | 1939 | ▶ | $options //= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$options //= {}
MC/DC100%1/1
$options //= {}
$options
Truth table100%2/2
A
A= $options
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | my $self = bless { | ||||||||||||||||||||||||||||||||||||||||||
| 35 | environment => $options->{environment} // \%ENV, | ||||||||||||||||||||||||||||||||||||||||||
| 36 | user_agent_extensions => $options->{user_agent_extensions} // [], | ||||||||||||||||||||||||||||||||||||||||||
| 37 | 1939 | ▶ | http_client => $options->{http_client} // Twilio::Http::TinyClient->new, | ||||||||||||||||||||||||||||||||||||||||
|
Condition85%6/7
$options->{"environment"} // \%ENV
$options->{"user_agent_extensions"} // []
$options->{"http_client"} // "Twilio::Http::TinyClient"->new
MC/DC100%1/1
$options->{"environment"} // \%ENV
$options->{"environment"}
MC/DC100%1/1
$options->{"user_agent_extensions"} // []
$options->{"user_agent_extensions"}
MC/DC0%0/2
$options->{"http_client"} // "Twilio::Http::TinyClient"->new
$options->{"http_client"}
"Twilio::Http::TinyClient"->new
Truth table100%2/2
A
A= $options->{"environment"}
Truth table100%2/2
A
A= $options->{"user_agent_extensions"}
Truth table66%2/3
A // B
A= $options->{"http_client"}B= "Twilio::Http::TinyClient"->new
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 1939 | $self->set_username($self->get_arg($username, $ENV_ACCOUNT_SID)); | |||||||||||||||||||||||||||||||||||||||||
| 41 | 1939 | $self->set_password($self->get_arg($password, $ENV_AUTH_TOKEN)); | |||||||||||||||||||||||||||||||||||||||||
| 42 | 1939 | ▶ | $self->set_account_sid($options->{account_sid} // $self->get_username); | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$options->{"account_sid"} // $self->get_username
MC/DC100%2/2
$options->{"account_sid"} // $self->get_username
$options->{"account_sid"}
$self->get_username
Truth table100%3/3
A // B
A= $options->{"account_sid"}B= $self->get_username
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 1939 | $self->{region} = $self->get_arg($options->{region}, $ENV_REGION); | |||||||||||||||||||||||||||||||||||||||||
| 44 | 1939 | $self->{edge} = $self->get_arg($options->{edge}, $ENV_EDGE); | |||||||||||||||||||||||||||||||||||||||||
| 45 | 1939 | $self->{log_level} = $self->get_arg(undef, $ENV_LOG_LEVEL); | |||||||||||||||||||||||||||||||||||||||||
| 46 | 1939 | $self->set_max_retries($options->{max_retries}); | |||||||||||||||||||||||||||||||||||||||||
| 47 | $self->set_credential_provider($options->{credential_provider}) | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 1935 | ▶ | if $options->{credential_provider}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 1934 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 9721 | ▶ | sub get_arg { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_arg: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 9721 | my ($self, $arg, $env_var) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 55 | 9721 | ▶ | return $arg if defined $arg && length $arg; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $arg and length $arg
MC/DC50%1/2
defined $arg and length $arg
defined $arg
length $arg
Truth table66%2/3
A and B
A= defined $argB= length $arg
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 5904 | return $self->{environment}{$env_var}; | |||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 1937 | ▶ | sub request { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
request: called CC=16 SCAR=27.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 1937 | my ($self, $method, $uri, $options) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 61 | 1937 | ▶ | $options //= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$options //= {}
MC/DC100%1/1
$options //= {}
$options
Truth table100%2/2
A
A= $options
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 1937 | $method = uc $method; | |||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | # A username and password win over a provider, as in twilio-php. Setting a provider clears the | ||||||||||||||||||||||||||||||||||||||||||
| 65 | # client's own, so they only apply when given again, to the client or to one request. | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 1937 | ▶ | my $username = $options->{username} || $self->get_username; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$options->{'username'} || $self->get_username
MC/DC100%2/2
$options->{'username'} || $self->get_username
$options->{'username'}
$self->get_username
Truth table100%3/3
A || B
A= $options->{'username'}B= $self->get_username
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 1937 | ▶ | my $password = $options->{password} || $self->get_password; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$options->{'password'} || $self->get_password
MC/DC100%2/2
$options->{'password'} || $self->get_password
$options->{'password'}
$self->get_password
Truth table100%3/3
A || B
A= $options->{'password'}B= $self->get_password
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 1937 | ▶ | my $strategy = $username && $password ? undef : $self->_auth_strategy; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$username and $password
MC/DC100%2/2
$username and $password
$username
$password
Truth table100%3/3
A and B
A= $usernameB= $password
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 1937 | ▶ | if (!$strategy) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 1893 | ▶ | Twilio::Exceptions::ConfigurationException->throw('username is required') if !$username; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 1891 | ▶ | Twilio::Exceptions::ConfigurationException->throw('password is required') if !$password; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | # Header options the caller did not set are left out, like any other option. | ||||||||||||||||||||||||||||||||||||||||||
| 75 | my %headers = | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 284 | map { $_ => $options->{headers}{$_} } grep { defined $options->{headers}{$_} } | |||||||||||||||||||||||||||||||||||||||||
| 77 | 1934 | ▶ | keys %{ $options->{headers} // {} }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$options->{"headers"} // {}
MC/DC100%1/1
$options->{"headers"} // {}
$options->{"headers"}
Truth table100%2/2
A
A= $options->{"headers"}
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 1934 | $headers{'User-Agent'} = $self->_user_agent; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 1934 | $headers{'Accept-Charset'} = 'utf-8'; | |||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | # Delete responses have no body to negotiate. | ||||||||||||||||||||||||||||||||||||||||||
| 82 | 1934 | ▶ | $headers{Accept} //= 'application/json' if $method ne 'DELETE'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$headers{"Accept"} //= "application/json"
MC/DC100%1/1
$headers{"Accept"} //= "application/json"
$headers{"Accept"}
Truth table100%2/2
A
A= $headers{"Accept"}
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | # An Authorization header from the caller is Flex Insights' own token, and it is sent instead. | ||||||||||||||||||||||||||||||||||||||||||
| 85 | 1934 | my $given = grep { lc eq 'authorization' } keys %headers; | |||||||||||||||||||||||||||||||||||||||||
| 86 | 1934 | ▶ | if ($strategy && $strategy->requires_authentication && !$given) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$strategy and $strategy->requires_authentication and not $given
$strategy and $strategy->requires_authentication
MC/DC100%3/3
$strategy and $strategy->requires_authentication and not $given
$strategy
$strategy->requires_authentication
not $given
Truth table100%4/4
A and B and not(C)
A= $strategyB= $strategy->requires_authenticationC= not $given
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 23 | $headers{Authorization} = $strategy->get_auth_string($self); | |||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | my $response = $self->_send_with_retries( | ||||||||||||||||||||||||||||||||||||||||||
| 91 | $method, | ||||||||||||||||||||||||||||||||||||||||||
| 92 | $self->build_uri($uri), | ||||||||||||||||||||||||||||||||||||||||||
| 93 | { | ||||||||||||||||||||||||||||||||||||||||||
| 94 | 1931 | %{$options}, | |||||||||||||||||||||||||||||||||||||||||
| 95 | headers => \%headers, | ||||||||||||||||||||||||||||||||||||||||||
| 96 | username => $username, | ||||||||||||||||||||||||||||||||||||||||||
| 97 | password => $password, | ||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||
| 99 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 1930 | ▶ | push @{ $self->{captured_responses} }, $response if $self->{captured_responses}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 1930 | return $response; | |||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | # Scoped to $code, so the answers to other callers of a shared client are never mixed in. An | ||||||||||||||||||||||||||||||||||||||||||
| 105 | # OAuth token comes through a client of its own, so its answer is not among these. | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 14 | ▶ | sub capture_responses { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
capture_responses: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 14 | my ($self, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 108 | 14 | local $self->{captured_responses} = []; | |||||||||||||||||||||||||||||||||||||||||
| 109 | 14 | my $result = $code->(); | |||||||||||||||||||||||||||||||||||||||||
| 110 | 13 | return ($result, @{ $self->{captured_responses} }); | |||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | # Only 429 is retried: Twilio has refused the request, so repeating it cannot send anything | ||||||||||||||||||||||||||||||||||||||||||
| 114 | # twice. After a 5xx or a broken connection, a POST may already have sent its message. | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 1931 | ▶ | sub _send_with_retries { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_send_with_retries: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 1931 | my ($self, $method, $url, $options) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 1931 | my $response = $self->_send($method, $url, $options); | |||||||||||||||||||||||||||||||||||||||||
| 119 | 1930 | for my $attempt (1 .. $self->get_max_retries) { | |||||||||||||||||||||||||||||||||||||||||
| 120 | 46 | my $wait = _retry_wait($response, $attempt); | |||||||||||||||||||||||||||||||||||||||||
| 121 | 46 | ▶ | last if !defined $wait; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 30 | $self->_sleep($wait); | |||||||||||||||||||||||||||||||||||||||||
| 123 | 30 | $response = $self->_send($method, $url, $options); | |||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||
| 125 | 1930 | return $response; | |||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | 1961 | ▶ | sub _send { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_send: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | 1961 | my ($self, $method, $url, $options) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 1961 | my $log_debug = $self->_log_debug_enabled; | |||||||||||||||||||||||||||||||||||||||||
| 132 | 1961 | ▶ | _log_request($method, $url, $options->{params}, $options->{headers}) if $log_debug; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | 1961 | my $response = $self->get_http_client->request($method, $url, $options); | |||||||||||||||||||||||||||||||||||||||||
| 134 | 1960 | ▶ | _log_response($response) if $log_debug; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | 1960 | return $response; | |||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 46 | ▶ | sub _retry_wait { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_retry_wait: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 46 | my ($response, $attempt) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 140 | 46 | ▶ | return if $response->get_status_code != $STATUS_TOO_MANY_REQUESTS; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | 31 | my $retry_after = _retry_after($response->get_headers); | |||||||||||||||||||||||||||||||||||||||||
| 143 | 31 | ▶ | if (defined $retry_after) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | # Retrying sooner than Twilio asked would only use up an attempt, and waiting longer than | ||||||||||||||||||||||||||||||||||||||||||
| 146 | # the limit could hang a web request, so a long wait is the caller's to decide. | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 8 | ▶ | return $retry_after <= $RETRY_MAX_WAIT_SECONDS ? $retry_after : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 23 | my $backoff = $RETRY_BACKOFF_BASE**($attempt - 1); | |||||||||||||||||||||||||||||||||||||||||
| 151 | 23 | ▶ | return $backoff < $RETRY_MAX_WAIT_SECONDS ? $backoff : $RETRY_MAX_WAIT_SECONDS; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | # The date form of Retry-After is not read: it would depend on the local clock, and the | ||||||||||||||||||||||||||||||||||||||||||
| 155 | # backoff is a safe answer to it. | ||||||||||||||||||||||||||||||||||||||||||
| 156 | 31 | ▶ | sub _retry_after { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_retry_after: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 31 | my ($headers) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 158 | 31 | my ($name) = grep { lc $_ eq 'retry-after' } keys %{$headers}; | |||||||||||||||||||||||||||||||||||||||||
| 159 | 31 | ▶ | return if !defined $name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 12 | ▶ | my ($seconds) = ($headers->{$name} // q{}) =~ /\A\s*([0-9]+)\s*\z/; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$headers->{$name} // ""
MC/DC0%0/1
$headers->{$name} // ""
$headers->{$name}
Truth table50%1/2
A
A= $headers->{$name}
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 12 | return $seconds; | |||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 30 | ▶ | sub _sleep { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sleep: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 30 | my ($self, $seconds) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 167 | 30 | sleep $seconds; | |||||||||||||||||||||||||||||||||||||||||
| 168 | 30 | return; | |||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | 1941 | ▶ | sub build_uri { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_uri: called CC=12 SCAR=25.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | 1941 | my ($self, $uri) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 173 | 1941 | my ($edge, $region) = ($self->{edge}, $self->{region}); | |||||||||||||||||||||||||||||||||||||||||
| 174 | 1941 | ▶ | return $uri if !$edge && !$region; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$edge or $region
MC/DC100%2/2
$edge or $region
$edge
$region
Truth table100%3/3
A or B
A= $edgeB= $region
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | 17 | my ($scheme, $host, $rest) = $uri =~ m{\A([a-z]+://)([^/:?#]+)(.*)\z}is; | |||||||||||||||||||||||||||||||||||||||||
| 177 | 17 | ▶ | return $uri if !defined $host; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | 17 | my @pieces = split /[.]/, $host; | |||||||||||||||||||||||||||||||||||||||||
| 180 | 17 | ▶ | return $uri if @pieces < 3; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | 16 | ▶ | if (@pieces == $PIECES_WITH_REGION) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | 1 | ▶ | $region ||= $pieces[1]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$region ||= $pieces[1]
MC/DC0%0/2
$region ||= $pieces[1]
$region
$pieces[1]
Truth table33%1/3
A ||= B
A= $regionB= $pieces[1]
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||
| 185 | elsif (@pieces == $PIECES_WITH_EDGE) { | ||||||||||||||||||||||||||||||||||||||||||
| 186 | 2 | ▶ | $edge ||= $pieces[1]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$edge ||= $pieces[1]
MC/DC0%0/2
$edge ||= $pieces[1]
$edge
$pieces[1]
Truth table66%2/3
A ||= B
A= $edgeB= $pieces[1]
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | 2 | ▶ | $region ||= $pieces[2]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$region ||= $pieces[2]
MC/DC0%0/2
$region ||= $pieces[2]
$region
$pieces[2]
Truth table33%1/3
A ||= B
A= $regionB= $pieces[2]
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||
| 189 | 16 | ▶ | $region ||= $DEFAULT_REGION if $edge; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$region ||= $DEFAULT_REGION
MC/DC0%0/2
$region ||= $DEFAULT_REGION
$region
$DEFAULT_REGION
Truth table66%2/3
A ||= B
A= $regionB= $DEFAULT_REGION
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 16 | my $domain = join q{.}, @pieces[-2, -1]; | |||||||||||||||||||||||||||||||||||||||||
| 192 | 16 | return $scheme . join(q{.}, grep { $_ } $pieces[0], $edge, $region, $domain) . $rest; | |||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | 2 | ▶ | sub validate_ssl_certificate { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
validate_ssl_certificate: called CC=4 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | 2 | my ($self, $http_client) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 197 | 2 | ▶ | $http_client //= $self->get_http_client; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$http_client //= $self->get_http_client
MC/DC0%0/2
$http_client //= $self->get_http_client
$http_client
$self->get_http_client
Truth table33%1/3
A //= B
A= $http_clientB= $self->get_http_client
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 2 | my $response = $http_client->request('GET', 'https://tls-test.twilio.com:443'); | |||||||||||||||||||||||||||||||||||||||||
| 200 | 2 | my $status = $response->get_status_code; | |||||||||||||||||||||||||||||||||||||||||
| 201 | 2 | ▶ | if ($status < 200 || $status > 300) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$status < 200 or $status > 300
MC/DC50%1/2
$status < 200 or $status > 300
$status < 200
$status > 300
Truth table66%2/3
A or B
A= $status < 200B= $status > 300
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | 1 | Twilio::Exceptions::TwilioException->throw('Failed to validate SSL certificate'); | |||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||
| 204 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | 47 | ▶ | sub _auth_strategy { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_auth_strategy: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | 47 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 209 | 47 | ▶ | my $provider = $self->get_credential_provider or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | 44 | return $provider->to_auth_strategy; | |||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | 51 | ▶ | sub get_credential_provider { return $_[0]{credential_provider} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_credential_provider: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | 19 | ▶ | sub get_environment { return $_[0]{environment} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_environment: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | 49 | ▶ | sub set_credential_provider { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_credential_provider: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 217 | 49 | my ($self, $credential_provider) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 218 | 49 | ▶ | if (!blessed($credential_provider) || !$credential_provider->can('to_auth_strategy')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
builtin::blessed($credential_provider) and $credential_provider->can("to_auth_strategy")
MC/DC100%2/2
builtin::blessed($credential_provider) and $credential_provider->can("to_auth_strategy")
builtin::blessed($credential_provider)
$credential_provider->can("to_auth_strategy")
Truth table100%3/3
A and B
A= builtin::blessed($credential_provider)B= $credential_provider->can("to_auth_strategy")
| |||||||||||||||||||||||||||||||||||||||||||
| 219 | 5 | Twilio::Exceptions::ConfigurationException->throw( | |||||||||||||||||||||||||||||||||||||||||
| 220 | 'credential_provider must be a Twilio::CredentialProvider::CredentialProvider'); | ||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||
| 222 | 44 | $self->{credential_provider} = $credential_provider; | |||||||||||||||||||||||||||||||||||||||||
| 223 | 44 | $self->invalidate_basic_auth; | |||||||||||||||||||||||||||||||||||||||||
| 224 | 44 | return; | |||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | 45 | ▶ | sub invalidate_basic_auth { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
invalidate_basic_auth: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | 45 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 229 | 45 | $self->{username} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 230 | 45 | $self->{password} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 231 | 45 | return; | |||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | 1 | ▶ | sub invalidate_oauth { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
invalidate_oauth: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 236 | 1 | $self->{credential_provider} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 237 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | 3876 | ▶ | sub get_username { return $_[0]{username} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_username: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | 1943 | ▶ | sub get_password { return $_[0]{password} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_password: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | 126 | ▶ | sub get_account_sid { return $_[0]{account_sid} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_account_sid: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | 22 | ▶ | sub get_region { return $_[0]{region} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_region: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | 24 | ▶ | sub get_edge { return $_[0]{edge} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_edge: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | 2105 | ▶ | sub get_http_client { return $_[0]{http_client} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_http_client: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 1981 | ▶ | sub get_log_level { return $_[0]{log_level} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_log_level: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | 1953 | ▶ | sub get_max_retries { return $_[0]{max_retries} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_max_retries: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | 1941 | ▶ | sub set_username { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_username: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | 1941 | my ($self, $username) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 251 | 1941 | $self->{username} = $username; | |||||||||||||||||||||||||||||||||||||||||
| 252 | 1941 | return; | |||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | 1941 | ▶ | sub set_password { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_password: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | 1941 | my ($self, $password) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 257 | 1941 | $self->{password} = $password; | |||||||||||||||||||||||||||||||||||||||||
| 258 | 1941 | return; | |||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | 1940 | ▶ | sub set_account_sid { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_account_sid: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 262 | 1940 | my ($self, $account_sid) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 263 | 1940 | $self->{account_sid} = $account_sid; | |||||||||||||||||||||||||||||||||||||||||
| 264 | 1940 | return; | |||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | 1942 | ▶ | sub set_max_retries { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_max_retries: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 268 | 1942 | my ($self, $max_retries) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 269 | 1942 | ▶ | $max_retries //= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$max_retries //= 0
MC/DC100%1/1
$max_retries //= 0
$max_retries
Truth table100%2/2
A
A= $max_retries
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | 1942 | ▶ | if ($max_retries !~ /\A[0-9]+\z/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | 5 | Twilio::Exceptions::ConfigurationException->throw('max_retries must be a whole number'); | |||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||
| 273 | 1937 | $self->{max_retries} = $max_retries; | |||||||||||||||||||||||||||||||||||||||||
| 274 | 1937 | return; | |||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | 2 | ▶ | sub set_edge { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_edge: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | 2 | my ($self, $edge) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 279 | 2 | $self->{edge} = $self->get_arg($edge, $ENV_EDGE); | |||||||||||||||||||||||||||||||||||||||||
| 280 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | 1 | ▶ | sub set_http_client { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_http_client: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | 1 | my ($self, $http_client) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 285 | 1 | $self->{http_client} = $http_client; | |||||||||||||||||||||||||||||||||||||||||
| 286 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | 24 | ▶ | sub set_log_level { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_log_level: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 290 | 24 | my ($self, $log_level) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 291 | 24 | $self->{log_level} = $self->get_arg($log_level, $ENV_LOG_LEVEL); | |||||||||||||||||||||||||||||||||||||||||
| 292 | 24 | return; | |||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | 1934 | ▶ | sub _user_agent { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_user_agent: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 296 | 1934 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 297 | 1934 | my ($system, undef, undef, undef, $machine) = POSIX::uname(); | |||||||||||||||||||||||||||||||||||||||||
| 298 | 1934 | my $agent = sprintf 'twilio-perl/%s (%s %s) Perl/%vd', Twilio->VERSION, $system, $machine, $^V; | |||||||||||||||||||||||||||||||||||||||||
| 299 | 1934 | return join q{ }, $agent, @{ $self->{user_agent_extensions} }; | |||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | 1961 | ▶ | sub _log_debug_enabled { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_log_debug_enabled: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | 1961 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 304 | 1961 | ▶ | return 1 if ($self->{environment}{DEBUG_HTTP_TRAFFIC} // q{}) eq 'true'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$self->{"environment"}{"DEBUG_HTTP_TRAFFIC"} // ""
MC/DC100%1/1
$self->{"environment"}{"DEBUG_HTTP_TRAFFIC"} // ""
$self->{"environment"}{"DEBUG_HTTP_TRAFFIC"}
Truth table100%2/2
A
A= $self->{"environment"}{"DEBUG_HTTP_TRAFFIC"}
| |||||||||||||||||||||||||||||||||||||||||||
| 305 | 1960 | ▶ | return ($self->get_log_level // q{}) eq 'debug'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->get_log_level // ""
MC/DC100%1/1
$self->get_log_level // ""
$self->get_log_level
Truth table100%2/2
A
A= $self->get_log_level
| |||||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||
| 308 | 7 | ▶ | sub _log_request { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_log_request: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 309 | 7 | my ($method, $url, $params, $headers) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 310 | 7 | warn "-- BEGIN Twilio API Request --\n"; | |||||||||||||||||||||||||||||||||||||||||
| 311 | 7 | warn "Request Method: $method\n"; | |||||||||||||||||||||||||||||||||||||||||
| 312 | 7 | warn "Request URL: $url\n"; | |||||||||||||||||||||||||||||||||||||||||
| 313 | 7 | ▶ | warn "Query Params: $_=$params->{$_}\n" for sort keys %{ $params // {} }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$params // {}
MC/DC100%1/1
$params // {}
$params
Truth table100%2/2
A
A= $params
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | 7 | warn "Request Headers:\n"; | |||||||||||||||||||||||||||||||||||||||||
| 315 | 7 | warn "$_: $headers->{$_}\n" for grep { !/authorization/i } sort keys %{$headers}; | |||||||||||||||||||||||||||||||||||||||||
| 316 | 7 | warn "-- END Twilio API Request --\n"; | |||||||||||||||||||||||||||||||||||||||||
| 317 | 7 | return; | |||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | 7 | ▶ | sub _log_response { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_log_response: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | 7 | my ($response) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 322 | 7 | my $headers = $response->get_headers; | |||||||||||||||||||||||||||||||||||||||||
| 323 | 7 | warn 'Status Code: ' . $response->get_status_code . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 324 | 7 | warn "Response Headers:\n"; | |||||||||||||||||||||||||||||||||||||||||
| 325 | 7 | warn "$_: $headers->{$_}\n" for sort keys %{$headers}; | |||||||||||||||||||||||||||||||||||||||||
| 326 | 7 | return; | |||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | 20 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||
| 331 | __END__ | ||||||||||||||||||||||||||||||||||||||||||