File Coverage

blib/lib/Plack/Middleware/RemoveRedundantBody.pm
Criterion Covered Total %
statement 21 21 100.0
branch 4 4 100.0
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 32 32 100.0


line stmt bran cond sub pod time code
1             package Plack::Middleware::RemoveRedundantBody;
2 1     1   643 use strict;
  1         3  
  1         29  
3 1     1   5 use warnings;
  1         2  
  1         30  
4 1     1   5 use parent qw( Plack::Middleware );
  1         2  
  1         7  
5 1     1   60 use Plack::Util;
  1         2  
  1         237  
6              
7             our $VERSION = "0.09";
8              
9             # ABSTRACT: Plack::Middleware which removes body for HTTP response if it's not required
10              
11             sub call {
12 19     19 1 83950 my ($self, $env) = @_;
13              
14 19         64 my $res = $self->app->($env);
15              
16             return $self->response_cb($res, sub {
17 19     19   509 my $response = shift;
18 19 100       66 return unless @$response == 3;
19 17 100       47 return if ( !Plack::Util::status_with_no_entity_body($response->[0]) );
20 14         168 $response->[2] = [];
21 14         59 Plack::Util::header_remove($response->[1], "Content-Length");
22 14         279 return;
23 19         4054 });
24             }
25              
26             1;
27              
28             __END__