line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Test::Server; |
2
|
10
|
|
|
10
|
|
75
|
use strict; |
|
10
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
331
|
|
3
|
10
|
|
|
10
|
|
52
|
use warnings; |
|
10
|
|
|
|
|
23
|
|
|
10
|
|
|
|
|
257
|
|
4
|
10
|
|
|
10
|
|
50
|
use Carp; |
|
10
|
|
|
|
|
15
|
|
|
10
|
|
|
|
|
644
|
|
5
|
10
|
|
|
10
|
|
464
|
use HTTP::Request; |
|
10
|
|
|
|
|
14376
|
|
|
10
|
|
|
|
|
402
|
|
6
|
10
|
|
|
10
|
|
5035
|
use HTTP::Response; |
|
10
|
|
|
|
|
66409
|
|
|
10
|
|
|
|
|
320
|
|
7
|
10
|
|
|
10
|
|
5131
|
use Test::TCP; |
|
10
|
|
|
|
|
687976
|
|
|
10
|
|
|
|
|
743
|
|
8
|
10
|
|
|
10
|
|
5388
|
use Plack::Loader; |
|
10
|
|
|
|
|
32
|
|
|
10
|
|
|
|
|
369
|
|
9
|
10
|
|
|
10
|
|
4217
|
use Plack::LWPish; |
|
10
|
|
|
|
|
37
|
|
|
10
|
|
|
|
|
2519
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
11
|
|
|
11
|
0
|
49
|
my($class, $app, %args) = @_; |
13
|
|
|
|
|
|
|
|
14
|
11
|
|
50
|
|
|
89
|
my $host = $args{host} || '127.0.0.1'; |
15
|
|
|
|
|
|
|
my $server = Test::TCP->new( |
16
|
|
|
|
|
|
|
listen => $args{listen}, |
17
|
|
|
|
|
|
|
host => $host, |
18
|
|
|
|
|
|
|
code => sub { |
19
|
0
|
|
|
0
|
|
0
|
my $sock_or_port = shift; |
20
|
|
|
|
|
|
|
my $server = Plack::Loader->auto( |
21
|
|
|
|
|
|
|
($args{listen} ? ( |
22
|
0
|
0
|
|
|
|
0
|
listen_sock => $sock_or_port, |
23
|
|
|
|
|
|
|
):( |
24
|
|
|
|
|
|
|
port => $sock_or_port, |
25
|
|
|
|
|
|
|
host => $host, |
26
|
|
|
|
|
|
|
)) |
27
|
|
|
|
|
|
|
); |
28
|
0
|
|
|
|
|
0
|
$server->run($app); |
29
|
0
|
|
|
|
|
0
|
exit; |
30
|
|
|
|
|
|
|
}, |
31
|
11
|
|
|
|
|
133
|
); |
32
|
|
|
|
|
|
|
|
33
|
11
|
|
|
|
|
650802
|
bless { server => $server, %args }, $class; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub port { |
37
|
15
|
|
|
15
|
0
|
159
|
my $self = shift; |
38
|
15
|
|
|
|
|
133
|
$self->{server}->port; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub request { |
42
|
15
|
|
|
15
|
0
|
95
|
my($self, $req) = @_; |
43
|
|
|
|
|
|
|
|
44
|
15
|
|
33
|
|
|
693
|
my $ua = $self->{ua} || Plack::LWPish->new( no_proxy => [qw/127.0.0.1/] ); |
45
|
|
|
|
|
|
|
|
46
|
15
|
|
|
|
|
83
|
$req->uri->scheme('http'); |
47
|
15
|
|
50
|
|
|
23735
|
$req->uri->host($self->{host} || '127.0.0.1'); |
48
|
15
|
|
|
|
|
2802
|
$req->uri->port($self->port); |
49
|
|
|
|
|
|
|
|
50
|
15
|
|
|
|
|
1468
|
return $ua->request($req); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |