line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Middleware::SuppressResponseCodes; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$Plack::Middleware::SuppressResponseCodes::VERSION = '0.2'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
#ABSTRACT: Return HTTP Status code 200 for errors on request |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
25110
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
43
|
|
8
|
1
|
|
|
1
|
|
864
|
use parent qw(Plack::Middleware); |
|
1
|
|
|
|
|
303
|
|
|
1
|
|
|
|
|
6
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Plack::Util; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub call { |
13
|
|
|
|
|
|
|
my($self, $env) = @_; |
14
|
|
|
|
|
|
|
my $res = $self->app->($env); |
15
|
|
|
|
|
|
|
Plack::Util::response_cb($res, sub { |
16
|
|
|
|
|
|
|
my $res = shift; |
17
|
|
|
|
|
|
|
if ( $res->[0] =~ /^[45]../ and |
18
|
|
|
|
|
|
|
$env->{QUERY_STRING} =~ /(?:^|&)suppress_response_codes(=([^&]+))?/ |
19
|
|
|
|
|
|
|
and !($1 and $2 =~ /^(0|false)$/) ) { |
20
|
|
|
|
|
|
|
$res->[0] = 200; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
}); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
1; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
__END__ |