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