Elasticsearch/Cxn/HTTPTiny.pm

filter: Statementstmt 65.2% 15 / 23 Branchbran 8.3% 1 / 12 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 80.0% 4 / 5 Podpod 0.0% 0 / 1 totaltotal 43.4% 20 / 46 CC 8 SCAR 25.3
CC
8
Cov
42%
_build_handle
20.0
error_from_text
13.6
BEGIN
1.0
CRAP 12.6
« Elasticsearch/Client/6_0/Scroll.pm ↑ Summary Elasticsearch/Role/Transport.pm »
1 package Search::Elasticsearch::Cxn::HTTPTiny;
2 29 $Search::Elasticsearch::Cxn::HTTPTiny::VERSION = '6.80';
3 29 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 29 with 'Search::Elasticsearch::Role::Cxn', 'Search::Elasticsearch::Role::Is_Sync';
5  
6 29 ▶use HTTP::Tiny 0.043 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 29 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 29 my $Cxn_Error = qr/ Connection.(?:timed.out|re(?:set|fused))
10 | connect:.timeout
11 | Host.is.down
12 | No.route.to.host
13 | temporarily.unavailable
14 /x;
15  
16 #===================================
17 sub perform_request {
18 #===================================
19 my ( $self, $params ) = @_;
20 my $uri = $self->build_uri($params);
21 my $method = $params->{method};
22  
23 my %args;
24 if ( defined $params->{data} ) {
25 $args{content} = $params->{data};
26 $args{headers}{'Content-Type'} = $params->{mime_type};
27 $args{headers}{'Content-Encoding'} = $params->{encoding}
28 if $params->{encoding};
29 }
30  
31 my $handle = $self->handle;
32 $handle->timeout( $params->{timeout} || $self->request_timeout );
33  
34 my $response = $handle->request( $method, "$uri", \%args );
35  
36 return $self->process_response(
37 $params, # request
38 $response->{status}, # code
39 $response->{reason}, # msg
40 $response->{content}, # body
41 $response->{headers} # headers
42 );
43 }
44  
45 #===================================
46 sub error_from_text {
47 #===================================
48 1 ▶ local $_ = $_[2];
Subroutine error_from_text: called CC=5 SCAR=26.1
Pod undocumented
49 return
50 1 ▶ /[Tt]imed out/ ? 'Timeout'
Branch: 4 branches
BranchTrueFalseTotal
/[Tt]imed out/ ? : 1 0 1
/Unexpected end of stream/ ? : 0 0 0
/SSL connection failed/ ? : 0 0 0
/$Cxn_Error/ ? : 0 0 0
51 : /Unexpected end of stream/ ? 'ContentLength'
52 : /SSL connection failed/ ? 'SSL'
53 : /$Cxn_Error/ ? 'Cxn'
54 : 'Request';
55 }
56  
57 #===================================
58 sub _build_handle {
59 #===================================
60 0 ▶ my $self = shift;
Subroutine _build_handle: not called CC=4 SCAR=30.0
61 0 my %args = ( default_headers => $self->default_headers );
62 0 ▶ if ( $self->is_https && $self->has_ssl_options ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_https and $self->has_ssl_options) 0 0 0
Condition0%0/3
$self->is_https and $self->has_ssl_options
!ll&&!rl&&r
000
MC/DC0%0/2
$self->is_https and $self->has_ssl_options
$self->is_https $self->has_ssl_options
Truth table0%0/3
A and B
A= $self->is_httpsB= $self->has_ssl_options
ABresult
0X0
100
111
63 0 $args{SSL_options} = $self->ssl_options;
64 0 ▶ if ( $args{SSL_options}{SSL_verify_mode} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"SSL_options"}{"SSL_verify_mode"}) 0 0 0
65 0 $args{verify_ssl} = 1;
66 }
67 }
68  
69 0 return HTTP::Tiny->new( %args, %{ $self->handle_args } );
70 }
71  
72 29 1;
73  
74 # ABSTRACT: A Cxn implementation which uses HTTP::Tiny
75  
76 __END__
« Elasticsearch/Client/6_0/Scroll.pm ↑ Summary Elasticsearch/Role/Transport.pm »