Proxy/BodyFilter/lines.pm

filter: Statementstmt 100% 40 / 40 Branchbran 100% 20 / 20 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 7 / 7 Podpod 100% 3 / 3 totaltotal 100% 75 / 75 CC 12 SCAR 16.1
CC
12
Cov
100%
init
7.0
filter
6.0
BEGIN
1.0
CRAP 5.0
« Proxy/Engine/Legacy.pm ↑ Summary Proxy/BodyFilter/simple.pm »
1 package HTTP::Proxy::BodyFilter::lines;
2 3 $HTTP::Proxy::BodyFilter::lines::VERSION = '0.304';
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use HTTP::Proxy::BodyFilter;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use vars qw( @ISA );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 @ISA = qw( HTTP::Proxy::BodyFilter );
8  
9 8 ▶sub init {
Subroutine init: called CC=7 SCAR=19.5
Pod documented
10 8 my $self = shift;
11  
12 8 ▶ croak "slurp mode is not supported. Use HTTP::Proxy::BodyFilter::store."
Branch: 1 branch
BranchTrueFalseTotal
if @_ and not defined $_[0] 1 7 8
Condition100%3/3
@_ and not defined $_[0]
!ll&&!rl&&r
251
MC/DC100%2/2
@_ and not defined $_[0]
@_ not defined $_[0]
Truth table100%3/3
A and not(B)
A= @_B= not defined $_[0]
ABresult
0X0
100
111
13 if @_ && not defined $_[0];
14  
15 7 ▶ my $eol = @_ ? $_[0] : "\n"; # FIXME shouldn't this be $/?
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 5 2 7
16 7 ▶ if ( ref $eol eq 'SCALAR' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $eol eq "SCALAR") 3 4 7
17 3 local $^W;
18 3 ▶ croak qq'"$$eol" is not numeric' if $$eol ne ( 0 + $$eol );
Branch: 1 branch
BranchTrueFalseTotal
if $$eol ne 0 + $$eol 1 2 3
19 2 ▶ croak "Records of size 0 are not supported" if $$eol == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $$eol == 0 1 1 2
20 }
21 5 $self->{eol} = $eol;
22 }
23  
24 15 ▶sub filter {
Subroutine filter: called CC=6 SCAR=17.9
Pod documented
25 15 my ( $self, $dataref, $message, $protocol, $buffer ) = @_;
26 15 ▶ return if not defined $buffer; # last "lines"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $buffer 4 11 15
27  
28 11 my $eol = $self->{eol};
29 11 ▶ if ( $eol eq "" ) { # paragraph mode
Branch: 2 branches
BranchTrueFalseTotal
if ($eol eq '') { } 2 9 11
elsif (ref $eol eq 'SCALAR') { } 2 7 9
30 # if $$dataref ends with \n\n, we cannot know if there are
31 # more white lines at the beginning of the next chunk of data
32 2 $$dataref =~ /^(.*\n\n)([^\n].*)/sg;
33 2 ▶ ( $$dataref, $$buffer) = defined $1 ? ($1, $2) : ("", $$dataref);
Branch: 1 branch
BranchTrueFalseTotal
defined $1 ? : 1 1 2
34 }
35 elsif ( ref $eol eq 'SCALAR' ) { # record mode
36 2 my $idx = length($$dataref) - length($$dataref) % $$eol;
37 2 $$buffer = substr( $$dataref, $idx );
38 2 $$dataref = substr( $$dataref, 0, $idx );
39 }
40 else {
41 7 my $idx = rindex( $$dataref, $eol );
42 7 ▶ if ( $idx == -1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($idx == -1) { } 1 6 7
43 1 $$buffer = $$dataref; # keep everything for later
44 1 $$dataref = '';
45 }
46 else {
47 6 $idx += length($eol);
48 6 $$buffer = substr( $$dataref, $idx );
49 6 $$dataref = substr( $$dataref, 0, $idx );
50 }
51 }
52 }
53  
54 1 ▶sub will_modify { 0 }
Subroutine will_modify: called CC=1 SCAR=0.0
Pod documented
55  
56 3 1;
57  
58 __END__
« Proxy/Engine/Legacy.pm ↑ Summary Proxy/BodyFilter/simple.pm »