line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Test::Server; |
2
|
10
|
|
|
10
|
|
58
|
use strict; |
|
10
|
|
|
|
|
17
|
|
|
10
|
|
|
|
|
262
|
|
3
|
10
|
|
|
10
|
|
39
|
use warnings; |
|
10
|
|
|
|
|
15
|
|
|
10
|
|
|
|
|
212
|
|
4
|
10
|
|
|
10
|
|
36
|
use Carp; |
|
10
|
|
|
|
|
21
|
|
|
10
|
|
|
|
|
524
|
|
5
|
10
|
|
|
10
|
|
465
|
use HTTP::Request; |
|
10
|
|
|
|
|
14271
|
|
|
10
|
|
|
|
|
317
|
|
6
|
10
|
|
|
10
|
|
3919
|
use HTTP::Response; |
|
10
|
|
|
|
|
58112
|
|
|
10
|
|
|
|
|
279
|
|
7
|
10
|
|
|
10
|
|
4066
|
use Test::TCP; |
|
10
|
|
|
|
|
561546
|
|
|
10
|
|
|
|
|
609
|
|
8
|
10
|
|
|
10
|
|
4263
|
use Plack::Loader; |
|
10
|
|
|
|
|
27
|
|
|
10
|
|
|
|
|
274
|
|
9
|
10
|
|
|
10
|
|
3734
|
use Plack::LWPish; |
|
10
|
|
|
|
|
24
|
|
|
10
|
|
|
|
|
2089
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
11
|
|
|
11
|
0
|
37
|
my($class, $app, %args) = @_; |
13
|
|
|
|
|
|
|
|
14
|
11
|
|
50
|
|
|
76
|
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
|
|
|
|
|
104
|
); |
32
|
|
|
|
|
|
|
|
33
|
11
|
|
|
|
|
456057
|
bless { server => $server, %args }, $class; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub port { |
37
|
15
|
|
|
15
|
0
|
129
|
my $self = shift; |
38
|
15
|
|
|
|
|
4242
|
$self->{server}->port; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub request { |
42
|
15
|
|
|
15
|
0
|
57
|
my($self, $req) = @_; |
43
|
|
|
|
|
|
|
|
44
|
15
|
|
33
|
|
|
512
|
my $ua = $self->{ua} || Plack::LWPish->new( no_proxy => [qw/127.0.0.1/] ); |
45
|
|
|
|
|
|
|
|
46
|
15
|
|
|
|
|
86
|
$req->uri->scheme('http'); |
47
|
15
|
|
50
|
|
|
23202
|
$req->uri->host($self->{host} || '127.0.0.1'); |
48
|
15
|
|
|
|
|
1945
|
$req->uri->port($self->port); |
49
|
|
|
|
|
|
|
|
50
|
15
|
|
|
|
|
1039
|
return $ua->request($req); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |