| 1 | package Twilio::Http::TinyClient; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 21 | ▶ | use 5.016; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 21 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 21 | ▶ | use parent 'Twilio::Http::Client'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 21 | ▶ | use HTTP::Tiny; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 21 | ▶ | use Twilio::Exceptions::EnvironmentException; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | 21 | ▶ | use Twilio::Http::Response; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 21 | our $VERSION = '2.001'; | |||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 21 | my $STATUS_INTERNAL_ERROR = 599; | |||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 32 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||
| 18 | 32 | my ($class, $options) = @_; | |||||||||||||||||||
| 19 | 32 | my $self = $class->SUPER::new($options); | |||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | # HTTP::Tiny resends all headers on a redirect, which could hand the Authorization | ||||||||||||||||||||
| 22 | # header to another host. PHP's curl client does not follow redirects either. | ||||||||||||||||||||
| 23 | 32 | ▶ | $self->{http_tiny} //= HTTP::Tiny->new(verify_SSL => 1, max_redirect => 0); | ||||||||||||||||||
|
Condition66%2/3
$self->{"http_tiny"} //= "HTTP::Tiny"->new("verify_SSL", 1, "max_redirect", 0)
MC/DC0%0/2
$self->{"http_tiny"} //= "HTTP::Tiny"->new("verify_SSL", 1, "max_redirect", 0)
$self->{"http_tiny"}
"HTTP::Tiny"->new("verify_SSL", 1, "max_redirect", 0)
Truth table66%2/3
A //= B
A= $self->{"http_tiny"}B= "HTTP::Tiny"->new("verify_SSL", 1, "max_redirect", 0)
| |||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 32 | return $self; | |||||||||||||||||||
| 26 | } | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 10 | ▶ | sub send_request { | ||||||||||||||||||
|
Subroutine
send_request: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||
| 29 | 10 | my ($self, $request) = @_; | |||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 10 | my $http_tiny = $self->{http_tiny}; | |||||||||||||||||||
| 32 | 10 | $http_tiny->timeout($request->{timeout}); | |||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 10 | my %arguments = (headers => $request->{headers}); | |||||||||||||||||||
| 35 | 10 | ▶ | $arguments{content} = $request->{content} if defined $request->{content}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 10 | my $result = $http_tiny->request($request->{method}, $request->{url}, \%arguments); | |||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 10 | ▶ | if ($result->{status} == $STATUS_INTERNAL_ERROR) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 40 | 3 | Twilio::Exceptions::EnvironmentException->throw($result->{content}); | |||||||||||||||||||
| 41 | } | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 7 | return Twilio::Http::Response->new($result->{status}, $result->{content}, $result->{headers}); | |||||||||||||||||||
| 44 | } | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | 21 | 1; | |||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | __END__ | ||||||||||||||||||||