line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Middleware::Devel::ForceResponse; |
2
|
2
|
|
|
2
|
|
13185
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
47
|
|
3
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
44
|
|
4
|
2
|
|
|
2
|
|
412
|
use parent 'Plack::Middleware'; |
|
2
|
|
|
|
|
223
|
|
|
2
|
|
|
|
|
9
|
|
5
|
2
|
|
|
2
|
|
10579
|
use Plack::Util::Accessor qw/rate response/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
8
|
|
6
|
2
|
|
|
2
|
|
889
|
use Plack::Response; |
|
2
|
|
|
|
|
14518
|
|
|
2
|
|
|
|
|
49
|
|
7
|
2
|
|
|
2
|
|
796
|
use HTTP::Status qw/status_message/; |
|
2
|
|
|
|
|
5010
|
|
|
2
|
|
|
|
|
434
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub prepare_app { |
12
|
1
|
|
|
1
|
1
|
69
|
my $self = shift; |
13
|
|
|
|
|
|
|
|
14
|
1
|
50
|
|
|
|
3
|
$self->rate or $self->rate(25); |
15
|
1
|
50
|
|
|
|
36
|
$self->response or $self->response([500]); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub call { |
19
|
1
|
|
|
1
|
1
|
12270
|
my($self, $env) = @_; |
20
|
|
|
|
|
|
|
|
21
|
1
|
50
|
33
|
|
|
3
|
if ( $self->rate >= 100 || rand(10000) <= rand($self->rate*100) ) { |
22
|
1
|
|
|
|
|
9
|
my $status = ${$self->response}[int rand(scalar(@{$self->response}))]; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
3
|
|
23
|
1
|
|
|
|
|
6
|
my $body = status_message($status); |
24
|
1
|
|
|
|
|
9
|
my $res = Plack::Response->new( |
25
|
|
|
|
|
|
|
$status, |
26
|
|
|
|
|
|
|
[ |
27
|
|
|
|
|
|
|
'Content-Type' => 'text/plain', |
28
|
|
|
|
|
|
|
'Content-Length' => length($body), |
29
|
|
|
|
|
|
|
], |
30
|
|
|
|
|
|
|
$body, |
31
|
|
|
|
|
|
|
); |
32
|
1
|
|
|
|
|
77
|
return $res->finalize; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
$self->app->($env); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
__END__ |