| 1 | package HTTP::Server::Simple::Recorder; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 3 | our $VERSION = '0.03'; | |||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 3 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 3 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 3 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 3 | ▶ | use IO::File; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 0 | ▶ | sub stdio_handle { | ||||||||||||||||||
|
Subroutine
stdio_handle: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||
| 12 | 0 | my $self = shift; | |||||||||||||||||||
| 13 | 0 | ▶ | if (@_) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 14 | 0 | my $handle = $_[0]; | |||||||||||||||||||
| 15 | 0 | $self->{'_recorder_stdio_handle'} = $handle; | |||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 0 | my $serial = ++ $self->{'_recorder_serial'}; | |||||||||||||||||||
| 18 | 0 | my $prefix = $self->recorder_prefix; | |||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | 0 | my $infile = "$prefix.$serial.in"; | |||||||||||||||||||
| 21 | 0 | my $outfile = "$prefix.$serial.out"; | |||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 0 | ▶ | my $in = IO::File->new("$infile", ">") or die "Couldn't open $infile: $!"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 24 | 0 | $in->autoflush(1); | |||||||||||||||||||
| 25 | 0 | ▶ | my $out = IO::File->new("$outfile", ">") or die "Couldn't open $outfile: $!"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 26 | 0 | $out->autoflush(1); | |||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 0 | $self->{'_recorder_stdin_handle'} = IO::Tee::Binmode->new($handle, $in); | |||||||||||||||||||
| 29 | 0 | $self->{'_recorder_stdout_handle'} = IO::Tee::Binmode->new($handle, $out); | |||||||||||||||||||
| 30 | } | ||||||||||||||||||||
| 31 | 0 | return $self->{'_recorder_stdio_handle'}; | |||||||||||||||||||
| 32 | } | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 0 | ▶ | sub stdin_handle { | ||||||||||||||||||
|
Subroutine
stdin_handle: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 35 | 0 | my $self = shift; | |||||||||||||||||||
| 36 | 0 | return $self->{'_recorder_stdin_handle'}; | |||||||||||||||||||
| 37 | } | ||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 0 | ▶ | sub stdout_handle { | ||||||||||||||||||
|
Subroutine
stdout_handle: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 40 | 0 | my $self = shift; | |||||||||||||||||||
| 41 | 0 | return $self->{'_recorder_stdout_handle'}; | |||||||||||||||||||
| 42 | } | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 0 | ▶ | sub recorder_prefix { "/tmp/http-server-simple-recorder"; } | ||||||||||||||||||
|
Subroutine
recorder_prefix: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | package IO::Tee::Binmode; | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | 3 | ▶ | use base qw/IO::Tee/; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | 0 | ▶ | sub BINMODE { | ||||||||||||||||||
|
Subroutine
BINMODE: not called CC=6 SCAR=37.4
| |||||||||||||||||||||
| 51 | 0 | my $self = shift; | |||||||||||||||||||
| 52 | 0 | my $ret = 1; | |||||||||||||||||||
| 53 | 0 | ▶ | if (@_) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 54 | 0 | ▶ | for my $fh (@$self) { undef $ret unless binmode $fh, $_[0] } | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 55 | } else { | ||||||||||||||||||||
| 56 | 0 | ▶ | for my $fh (@$self) { undef $ret unless binmode $fh } | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 57 | } | ||||||||||||||||||||
| 58 | 0 | return $ret; | |||||||||||||||||||
| 59 | } | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | 0 | ▶ | sub READ { | ||||||||||||||||||
|
Subroutine
READ: not called CC=3 SCAR=24.8
| |||||||||||||||||||||
| 62 | 0 | my $self = shift; | |||||||||||||||||||
| 63 | 0 | my $bytes = $self->[0]->read(@_); | |||||||||||||||||||
| 64 | # add the || 0 to silence warnings | ||||||||||||||||||||
| 65 | 0 | ▶ | $bytes and $self->_multiplex_input(substr($_[0], $_[2] || 0, $bytes)); | ||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$_[2] || 0
MC/DC0%0/1
$_[2] || 0
$_[2]
Truth table0%0/2
A
A= $_[2]
| |||||||||||||||||||||
| 66 | 0 | $bytes; | |||||||||||||||||||
| 67 | } | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | 3 | 1; # Magic true value required at end of module | |||||||||||||||||||
| 71 | __END__ | ||||||||||||||||||||