line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Test::MockHTTP; |
2
|
60
|
|
|
60
|
|
446
|
use strict; |
|
60
|
|
|
|
|
121
|
|
|
60
|
|
|
|
|
1857
|
|
3
|
60
|
|
|
60
|
|
334
|
use warnings; |
|
60
|
|
|
|
|
119
|
|
|
60
|
|
|
|
|
1589
|
|
4
|
|
|
|
|
|
|
|
5
|
60
|
|
|
60
|
|
327
|
use Carp; |
|
60
|
|
|
|
|
108
|
|
|
60
|
|
|
|
|
4618
|
|
6
|
60
|
|
|
60
|
|
2372
|
use HTTP::Request; |
|
60
|
|
|
|
|
62656
|
|
|
60
|
|
|
|
|
2125
|
|
7
|
60
|
|
|
60
|
|
29802
|
use HTTP::Response; |
|
60
|
|
|
|
|
399759
|
|
|
60
|
|
|
|
|
2080
|
|
8
|
60
|
|
|
60
|
|
29560
|
use HTTP::Message::PSGI; |
|
60
|
|
|
|
|
175
|
|
|
60
|
|
|
|
|
3556
|
|
9
|
60
|
|
|
60
|
|
442
|
use Try::Tiny; |
|
60
|
|
|
|
|
118
|
|
|
60
|
|
|
|
|
13672
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
117
|
|
|
117
|
0
|
330
|
my($class, $app) = @_; |
13
|
117
|
|
|
|
|
771
|
bless { app => $app }, $class; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub request { |
17
|
285
|
|
|
285
|
0
|
5737
|
my($self, $req) = @_; |
18
|
|
|
|
|
|
|
|
19
|
285
|
100
|
|
|
|
791
|
$req->uri->scheme('http') unless defined $req->uri->scheme; |
20
|
285
|
100
|
|
|
|
120886
|
$req->uri->host('localhost') unless defined $req->uri->host; |
21
|
285
|
|
|
|
|
24587
|
my $env = $req->to_psgi; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $res = try { |
24
|
285
|
|
|
285
|
|
14455
|
HTTP::Response->from_psgi($self->{app}->($env)); |
25
|
|
|
|
|
|
|
} catch { |
26
|
23
|
|
|
23
|
|
455
|
HTTP::Response->from_psgi([ 500, [ 'Content-Type' => 'text/plain' ], [ $_ ] ]); |
27
|
285
|
|
|
|
|
2094
|
}; |
28
|
|
|
|
|
|
|
|
29
|
285
|
|
|
|
|
5549
|
$res->request($req); |
30
|
285
|
|
|
|
|
6347
|
return $res; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
__END__ |