File Coverage

blib/lib/HTTP/Engine/Role/ResponseWriter/OutputBody.pm
Criterion Covered Total %
statement 13 13 100.0
branch 4 4 100.0
condition 6 6 100.0
subroutine 3 3 100.0
pod 0 1 0.0
total 26 27 96.3


line stmt bran cond sub pod time code
1             package HTTP::Engine::Role::ResponseWriter::OutputBody;
2 29     29   20312 use Any::Moose '::Role';
  29         63  
  29         228  
3              
4             has chunk_size => (
5             is => 'ro',
6             isa => 'Int',
7             default => 4096,
8             );
9              
10             sub output_body {
11 42     42 0 89 my($self, $body) = @_;
12              
13 29     29   14227 no warnings 'uninitialized';
  29         67  
  29         4423  
14 42 100 100     402 if ((Scalar::Util::blessed($body) && $body->can('read')) || (ref($body) eq 'GLOB')) {
      100        
15 5         1036 while (!eof $body) {
16 11         247 read $body, my ($buffer), $self->chunk_size;
17 11 100       59 last unless $self->write($buffer);
18             }
19 5         189 close $body;
20             } else {
21 37         162 $self->write($body);
22             }
23             }
24              
25             1;