Connection.pm untested

filter: Statementstmt 0.0% 0 / 22 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 52 CC 5 SCAR 28.7
CC
5
Cov
0%
process_response
30.0
decode_response
2.0
BEGIN
2.0
CRAP 17.6
1 package Apache::Tika::Connection;
2 use strict;
3 use Moo::Role;
4 use JSON::XS;
5 our $VERSION = '0.11';
6  
7 sub decode_response {
8 my( $self, $body ) = @_;
9  
10 return decode_json( $body );
11 }
12  
13 sub process_response {
14 my ( $self, $params, $code, $msg, $body, $headers ) = @_;
15  
16 my $mime_type = $headers->{"content-type"};
17  
18 my $is_encoded = $mime_type && $mime_type !~ m!^text/plain\b!;
19  
20 # Request is successful
21  
22 if ( $code >= 200 and $code <= 209 ) {
23 if ( defined $body and length $body ) {
24 # Let's hope it's JSON
25 $body = $self->decode_response($body)
26 if $is_encoded;
27 return $code, $body;
28 }
29 return ( $code, 1 ) if $params->{method} eq 'HEAD';
30 return ( $code, '' );
31 }
32  
33 # Check if the error should be ignored
34 return ($code, $body);
35 }
36  
37 1;
38  
39 =head1 REPOSITORY
40  
41 The public repository of this module is
42 L<https://github.com/Corion/Apache-Tika-Async>.
43  
44 =head1 SUPPORT
45  
46 The public support forum of this module is
47 L<https://perlmonks.org/>.
48  
49 =head1 BUG TRACKER
50  
51 Please report bugs in this module via the RT CPAN bug queue at
52 L<https://rt.cpan.org/Public/Dist/Display.html?Name=CORION-Apache-Tika>
53 or via mail to L<corion-apache-tika-Bugs@rt.cpan.org>.
54  
55 =head1 AUTHOR
56  
57 Max Maischein C<corion@cpan.org>
58  
59 =head1 COPYRIGHT (c)
60  
61 Copyright 2014-2019 by Max Maischein C<corion@cpan.org>.
62  
63 =head1 LICENSE
64  
65 This module is released under the same terms as Perl itself.
66  
67 =cut